<template>
  <div class="app-container" v-cloak>
    <div class="shop-container">
      <h3>商品信息</h3>
      <span v-if="(ruleForm.replaceDeliveryTime == 1) && (selectdelitimeFlag == false) ? true : false" class="timecolor" style="width: 86%;font-size: 20px;">更换配送时间</span>
      <nav v-loading="detailLoading">
        <li
          v-for="(detail,index) in shoplist"
          :key="index"
        >
          <span v-if="detail.productionState == 6 ? true : false" class="timecolor">此蛋糕无货，请联系用户更换蛋糕</span>
          <span v-if="detail.refundNotReturn === '退款不退货' ? true : false" class="timecolor">退款不退货</span>
          <span v-if="ruleForm.refundMark === '平台退款中' ? true : false" class="timecolor">平台退款中</span>
          <p style="display: flex;justify-content: space-between">
            <span><strong class="title-noEdit">蛋糕：</strong>{{ detail.goodsName }}</span>
          </p>
          <p><span><strong class="title-noEdit">规格：</strong>
              <span v-if="detail.goodsSpecsFlags !== true ? true : false">{{ detail.goodsSpecs }}</span>
              <!-- {{ detail.goodsSpecs }} -->
              <el-input v-show="((ruleForm.status == 1) && (detail.goodsSpecsFlags == true)) ? true : false" v-model.trim="detail.goodsSpecs" clearable maxlength="20" size="medium" style="width: 35%"></el-input>
            </span>
          </p>
          <p><span><strong class="title-noEdit">Sku码：</strong>
              <span v-if="ruleForm.status !== 1 ? true : false">{{ detail.skuCode }}</span>
              <!-- {{ detail.skuCode }} -->
              <el-input v-show="ruleForm.status == 1 ? true : false" v-model="detail.skuCode" clearable onkeyup="value=value.replace(/[^\-?\d.]/g,'').slice(0,20)" maxlength="20" onafterpaste="value=value.replace(/[^\-?\d.]/g,'').slice(0,20)" size="medium" style="width: 35%"></el-input>
            </span>
          </p>
          <p>
            <span><strong class="title-noEdit">价格：</strong>{{ (detail.totalPrice/100).toFixed(2) }}元</span>
            <!-- <span>数量：{{ detail.num }}</span> -->
          </p>
          <p>
            <span><strong class="title-noEdit">数量：</strong>{{detail.num}}</span>
          </p>
          <p><span><strong class="title-noEdit">状态：</strong>{{detail.productionStateName}}</span></p>
          <p>
            <span>
              <strong class="title-noEdit">商品类别：</strong>
              <strong
                v-if="ruleForm.status !== 1 ? true : false"
              >
                {{detail.goodsTypeName}}
              </strong>
            </span>
            <el-cascader v-if="ruleForm.status == 1 ? true : false" v-model="detail.categoryIdArray" clearable :placeholder="detail.goodsTypeName" :options="getCategoriesList" @change="selectCategory(detail.categoryIdArray,index)"
            :show-all-levels="false"></el-cascader>
            <!-- <el-cascader v-if="detail.cake == 2 && ruleForm.status == 1 ? true : false" v-model="detail.categoryIdArray" clearable placeholder="请选择商品类型" :options="getCategoriesList" @change="selectCategory(detail.categoryIdArray,index)"
            :show-all-levels="false"></el-cascader> -->
          </p>
          <p>
            <span><strong class="title-noEdit">祝福语：</strong>
              <el-input class="orderspecial" v-model.trim="detail.blessings" maxlength="16" show-word-limit autosize clearable size="medium" style="width: 45%"></el-input>
              <!-- {{ detail.blessings }} -->
            </span>
          </p>
        </li>
      </nav>
      <div v-if="ruleForm.status == 1 ? true : false" class="EditCake">
        <el-button type="primary" @click="openEditCake">编辑商品</el-button>
        <!-- <span style="line-height: 4">所选蛋糕总价：</span> -->
        <!-- <span style="line-height: 4">￥ <i class="orderprice">{{ (todetaillist.originalPrice/100).toFixed(2) }}</i>元</span> -->
      </div>
    </div>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <div class="payment-container">
        <h3>支付</h3>
        <el-form-item label="在线支付" prop="totalPrice">
          <el-input v-model.trim="ruleForm.sumPrice" maxlength="9" oninput="value=value.replace(/[^\d.]/g,'')" placeholder="请填写价格" clearable size="medium"></el-input>
          <span style="margin-left: 15px;">元</span>
        </el-form-item>
      </div>
      <div class="channel-container">
        <h3>渠道</h3>
        <el-form-item label="渠道类别" prop="channelType">
          <el-select v-model.trim="ruleForm.channelType" @keydown.native="channelFilter" size="medium" filterable placeholder="渠道类别">
            <el-option
              v-for="(channelitem,channel) in channelTypellist"
              :key="channel"
              :label="channelitem.channelName"
              :value="channelitem.channelKey"
            >
              <span
                :data-id="channelitem.id"
                :data-channelName="channelitem.channelKey"
                style="display: block;width: 100%;padding: 0 20px;margin-left: -20px;"
                @click="getchannelTypeId($event)"
              >{{ channelitem.channelName }}</span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="渠道" prop="channel">
          <el-select v-model.trim="ruleForm.channelName" @change="getChannel" @keydown.native="channelFilter" size="medium" filterable placeholder="渠道">
            <el-option
              v-for="(channelitem,channel) in channerllist"
              :key="channel"
              :label="channelitem.channelName"
              :value="{value:channelitem.channelKey,label:channelitem.channelName}"
            ></el-option>
          </el-select>
        </el-form-item>
      </div>
      <div class="detail-container">
        <h3>订单信息</h3>
        <el-form-item label="后台单号" prop="xmbzNo">
          <el-col>{{ruleForm.xmbzNo}}</el-col>
        </el-form-item>
        <el-form-item label="平台单号">
          <!-- <el-col>{{ruleForm.platformOrderId}}</el-col> -->
          <el-input v-model.trim="ruleForm.platformOrderId" clearable size="medium"></el-input>
        </el-form-item>
        <el-form-item label="收货人" prop="receiverName">
          <el-input v-model.trim="ruleForm.receiverName" maxlength="10" onkeyup="value=value.replace(/\s+/g, '')" onafterpaste="value=value.replace(/\s+/g, '')" show-word-limit clearable size="medium"></el-input>
        </el-form-item>
        <el-form-item label="电话" prop="receiverPhone">
          <el-input type="text" v-model.trim="ruleForm.receiverPhone" maxlength="50" @input="filterPhone" show-word-limit autosize clearable size="medium"></el-input>
        </el-form-item>
        <el-form-item label="客户备注" prop="customerNotes">
          <el-input class="orderspecial" v-model="ruleForm.customerNotes" type="textarea" maxlength="50" @input="filterSpace('customerNotes')" show-word-limit autosize clearable size="medium"></el-input>
        </el-form-item>
        <el-form-item label="生产备注" prop="productionNotes">
          <el-input v-model="ruleForm.productionNotes" type="textarea" maxlength="50" @input="filterSpace('productionNotes')" show-word-limit autosize clearable size="medium"></el-input>
        </el-form-item>
        <el-form-item label="配送备注" prop="deliveryNotes">
          <el-input v-model="ruleForm.deliveryNotes" onkeydown="if(event.keyCode==13){event.keyCode=0;event.returnValue=false;}" type="textarea" maxlength="200" @input="filterSpace('deliveryNotes')" show-word-limit autosize clearable size="medium"></el-input>
        </el-form-item>
        <el-form-item label="客服备注" prop="customerServiceNotes">
          <el-input v-model="ruleForm.customerServiceNotes" type="textarea" maxlength="200" @input="filterSpace('customerServiceNotes')" show-word-limit autosize clearable size="medium"></el-input>
        </el-form-item>
        <el-form-item label="平台门店" prop="merchantName">
          <span>
            {{ ruleForm.merchantName }}
          </span>
        </el-form-item>
        <el-form-item v-if="ruleForm.groupBuyQRCode ? true : false" label="团购二维码" prop="groupBuyQRCode">
          <!-- <img :src="ruleForm.groupBuyQRCode" alt="" @click="imgclick"> -->
          <img :src="ruleForm.groupBuyQRCode" alt="" style="width: 450px;height: 450px;">
          <!-- <span>
            {{ ruleForm.groupBuyQRCode }}
          </span> -->
        </el-form-item>
      </div>
      <div class="address-container">
        <h3>配送地址和时间</h3>
        <el-form-item label="配送时间" prop="deliveryStartTime" class="deliveryTimeStyle">
          <el-col>客户备注时间：{{ this.PendingStartTime }}~{{ this.PendingEndTime }}</el-col>
          <el-col v-if="getdeliverytimeFlag == true ? true : false">{{ ruleForm.StartTime }}~{{ ruleForm.EndTime }}</el-col>
          <div style="display: flex;margin-left: -10px;">
            <el-date-picker
              type="date"
              size="medium"
              :placeholder="getdelOrderStartTime"
              v-model="getdeliveryStartTime"
              :picker-options="pickerOptionsStart"
              :clearable="false"
              value-format="yyyy-MM-dd "
              :disabled="orderStatus == 8 || ruleForm.receivedTime !== ''"
              format="yyyy-MM-dd "
              style="width: 170px;margin: 0 0 0 10px;"
            ></el-date-picker>
            <div class="line" :span="1" style="margin:  0 10px;">-</div>
            <selecttime
              ref="getdeliveryTime"
              v-bind:deliveryTime="getdeliveryStartTime"
              v-bind:OrderStartTime="ruleForm.deliveryStartTime"
              v-bind:OrderEndTime="ruleForm.deliveryEndTime"
              v-bind:OrderTimeFlag="OrderTimeFlag"
              v-bind:Orderstatus="ruleForm.status"
              v-bind:receivedTime="ruleForm.receivedTime"
              style="width: 170px;margin: 0"
            ></selecttime>
          </div>
          <!-- <el-button type="primary" size="medium" plain @click="deliveryTimeOpen">选择时间</el-button> -->
        </el-form-item>
        <!-- <el-dialog
          title
          :visible.sync="deliveryTimeUpdateFlag"
          center
          :before-close="handleClose"
          :append-to-body="true"
          :lock-scroll="false"
          width="95%"
          z-index="2007"
        >
          <deliveryTime
            ref="getdeliveryTime"
            v-bind:timelist="timelist"
            v-bind:warehouseLoadList="warehouseLoadList"
            v-bind:checkedlist="checkedlist"
            v-bind:idList="idList"
            v-loading="detailLoading"
            v-bind:startTime="ruleForm.deliveryStartTime"
            v-bind:endTime="ruleForm.deliveryEndTime"
            v-bind:orderStartEndTime="orderStartEndTime"
            @getgetSurplusWarehouseLoadList="getgetSurplusWarehouseLoadList"
          ></deliveryTime>
          <el-col class="selectTimesubmit">
            <el-button type="primary" @click="selectSubmit">完成</el-button>
            <el-button type="primary" plain @click="cancelSelectTime" style="margin-left: 65px;">取消</el-button>
          </el-col>
        </el-dialog> -->
        <el-form-item label="仓库" class="house-style">
          <!-- <el-select v-model="ruleForm.wareHouse" placeholder="总仓" size="medium" style="width: 280px;margin-left: 5px;" @input="wareclick()">
            <el-option v-for="(house,ware) in citylist" :key="ware" :label="house.deptName" :value="house.id">
              <span :data-warehouseId="house.id" @click="getwareHouseOpen(house.deptName)" style="display: inline-block;width: 280px;padding: 0 20px;">{{ house.deptName }}</span>
            </el-option>
          </el-select> -->
          <el-select v-model="deptName" placeholder="城市" size="small" style="width: 130px;" @change="cityclick">
            <el-option v-for="(house,citykey) in cityselect" :key="citykey" :label="house.deptName" :value="{value:house.id,label:house.deptName}"></el-option>
          </el-select>
          <!-- <el-select v-model="ruleForm.deptId" clearable placeholder="城市" size="small" style="width: 130px;" @input="cityclick()">
            <el-option v-for="(house,citykey) in cityselect" :key="citykey" :label="house.deptName" :value="house.id"></el-option>
          </el-select> -->
          <el-select v-model="ruleForm.mainWarehouse" placeholder="仓库" size="medium" style="width: 280px;margin-left: 5px;">
            <el-option
              v-for="(house,ware) in citylist"
              :key="ware"
              :label="house.deptName"
              :value="house.deptName"
            >
              <span
                :data-id="house.id"
                style="display: block;width: 100%;padding: 0 20px;margin-left: -20px;"
                @click="wareclick($event)"
              >{{ house.deptName }}</span>
            </el-option>
          </el-select>
          <el-select v-model="ruleForm.branchWarehouse" placeholder="仓库" size="medium" style="width: 200px;margin-left: 5px;">
            <el-option v-for="(house,ware) in abbrlist" :key="ware" :label="house.name" :value="house.name">
              <span :data-warehouseId="house.id" @click="getwarehouseId(house.id)" style="display: inline-block;width: 200px;padding: 0 20px;margin-left: -20px;">{{ house.name }}</span>
            </el-option>
          </el-select>
          <!-- <el-input v-model="ruleForm.receiverAddress" size="medium" style="width: 280px;"></el-input>
          <el-input v-model="ruleForm.receiverDetailAddress" placeholder="详细地址" size="medium" style="width: 100px;margin-left: 10px;"></el-input> -->
        </el-form-item>
        <div>
          <el-form-item label="定位" class="getAddress deletePadding">
            <el-input
              type="textarea"
              id="getDetail"
              ref="search"
              placeholder="请输入地址"
              @keyup.up.native="selectTopItem()"
              @keyup.down.native="selectBottomItem()"
              @keydown.enter.native="getlnglat(currentIndex)"
              v-model="receiverDetailAddress"
              clearable
              size="medium"
              @focus="SearchAddress"
              @input="SearchAddress"
              maxlength="54"
              onkeyup="value=value.replace(/\s+/g, '')"
              onafterpaste="value=value.replace(/\s+/g, '')"
              show-word-limit
              autosize
              style="width: 480px;"
            ></el-input>
            <div class="adressDetailDivCopy" id='mapDiv'>
              <ul
                v-show="addressFlagcopy || isaddressFlagcopy"
                id='mapDiv'
                class="adressDetail"
              >
                <li
                  id='mapDiv'
                  v-for="(addressitem,index) in addressList.slice((currentPage-1)*pagesize,currentPage*pagesize)"
                  :key="index"
                  :class="currentIndex == index ? 'addressActive' : ''"
                  @click="getlnglat(index)"
                  @mouseover="changeColor(index)"
                  @mouseout="loseColor(index)"
                >
                  <p id='mapDiv' class="el-icon-location-information">{{ addressitem.name }}</p>
                  <p id='mapDiv' class="el-icon-location-information">地址：<span v-if="addressitem.address.length > 0 ? true : false">{{ addressitem.address }}</span></p>
                  <p id='mapDiv' class="el-icon-location-information">城市：<span v-if="addressitem.district !== ''? true : false">{{ addressitem.district }}</span></p>
                </li>
                <el-pagination
                  id='mapDiv'
                  v-show="addressFlagcopy || isaddressFlagcopy"
                  background
                  :current-page.sync="currentPage"
                  layout="prev, pager, next, sizes, total, jumper"
                  :page-sizes="[5, 10, 15, 20]"
                  :page-size.sync="pagesize"
                  :total="addressList.length"
                  @current-change="handleCurrentChange"
                  @size-change="handleSizeChange"
                  style="margin-top: 5px 0;"
                >
                </el-pagination>
              </ul>
            </div>
          </el-form-item>
          <el-form-item label="地址" prop="receiverAddress">
            <el-input
              id="getDetailAddress"
              type="textarea"
              v-model="ruleForm.receiverAddress"
              onkeyup="value=value.replace(/\s+/g, '')"
              onafterpaste="value=value.replace(/\s+/g, '')"
              placeholder="详细地址"
              maxlength="54"
              clearable
              show-word-limit
              autosize
              size="medium"
              class="deletePadding"
              style="width: 480px;"
            ></el-input>
          </el-form-item>
          <DetailMap id="amapDemoCopy" v-bind:mapCenter="mapCenter" v-bind:markers="markers" v-cloak></DetailMap>
          <el-col class="submit-order">
            <el-button size="medium" type="warning" @click="preservation('ruleForm')" style="margin-left: 20px;">保存信息</el-button>
            <el-button v-if="ruleForm.refundMark == '平台退款中'" type="warning" plain @click="PlaRefund">拒绝平台退款</el-button>
            <el-button v-if="RefundNoReFlag" type="danger" plain size="medium" @click="RefundNoRe" style="margin-left: 20px;">退款不退货</el-button>
            <el-button v-if="reminderOrderFlag" size="medium" @click="reminderOpen" style="margin-left: 20px;">催单</el-button>
            <el-button v-if="frmLossOrderFlag" size="medium" @click="frmLossOpen" style="margin-left: 20px;">备款</el-button>
            <el-button v-if="complainOrderFlag" size="medium" @click="complainOpen" style="margin-left: 20px;">投诉</el-button>
            <el-button v-if="returnOrderFlag" type="danger" size="medium" @click="returnGoodsOpen" style="margin-left: 20px;">退订</el-button>
            <el-button v-if="refundMoneyFlag" type="danger" size="medium" @click="refundOpen" style="margin-left: 20px;">退款</el-button>
            <el-button v-if="orderFlag" type="success" plain size="medium" @click="recoverOpen($event)" style="margin-left: 20px;">恢复订单</el-button>
            <!-- <el-button v-if="ruleForm.status !== 1 && journalFlag ? true : false" type="success" size="medium" @click="submitForm('ruleForm')" style="margin-left: 80px;margin-right: 130px;">修改订单</el-button> -->
            <el-button v-if="ruleForm.status == 1 && journalFlag ? true : false" type="success" size="medium" @click="submitForm('ruleForm')" style="margin-left: 80px;margin-right: 130px;">确认订单</el-button>
            <!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
          </el-col>
        </div>
      </div>
    </el-form>
    <!------------- 退订 --------------  -->
    <el-dialog
      title
      :visible.sync="returnGoodsFlag"
      :before-close="unsubscribeFormClose"
      center
      :append-to-body="true"
      :lock-scroll="false"
      width="50%"
      z-index="2007"
    >
      <div style="width: 100%;height: 430px;">
        <el-scrollbar class="page-component__scroll" style="height: 400px;">
          <el-col style="margin-top: 1%;">
            <!-- <returnGoods v-bind:my-message="returnGoodsFlag"></returnGoods> -->
            <el-col style="margin-top: 1%;">
              <div class="order-message" style="height: 35px;">
                <el-col style="padding-left: 5px;font-size: 20px;">退订</el-col>
              </div>
              <div style="height: 300px;margin-left: 25px;">
                <el-form
                  :model="unsubscribeForm"
                  :rules="unsubscribefRules"
                  ref="unsubscribeForm"
                  label-width="100px"
                  class="demo-ruleForm"
                >
                  <el-form-item v-if="refundCakeFlag" label="蛋糕">
                    <el-checkbox-group v-model="unsubscribeForm.orderDetailIds">
                      <el-checkbox
                        v-show="item.goodsTypeName == '蛋糕' && item.productionState !== 10 && item.productionState !== 11 && item.productionState !== 12 && item.refundNotReturn !== '退款不退货'"
                        v-for="(item,index) in shoplist"
                        :key="index"
                        :label="item.id"
                        :value="item.id"
                        :data-goods="item.goodsId"
                        name="type"
                        style="width: 325px;word-break: break-all;word-wrap:break-word;white-space: inherit;"
                      >{{ item.goodsName }}(规格：{{ item.goodsSpecs }},价格：{{ (item.totalPrice/100).toFixed(2) }})</el-checkbox>
                    </el-checkbox-group>
                  </el-form-item>
                  <el-form-item v-if="customCakeFlag" label="定制蛋糕">
                    <el-checkbox-group v-model="unsubscribeForm.customCake">
                      <el-checkbox
                        v-show="item.goodsTypeName == '定制蛋糕' && item.productionState !== 10 && item.productionState !== 11 && item.productionState !== 12 && item.refundNotReturn !== '退款不退货'"
                        v-for="(item,index) in shoplist"
                        :data-goods="item.goodsId"
                        :key="index"
                        :label="item.id"
                        :value="item.id"
                        name="type"
                        style="width: 325px;word-break: break-all;word-wrap:break-word;white-space: inherit;"
                      >{{ item.goodsName }}(规格：{{ item.goodsSpecs }},价格：{{ (item.totalPrice/100).toFixed(2) }})</el-checkbox>
                    </el-checkbox-group>
                  </el-form-item>
                  <el-form-item v-if="partsFlag" label="配件">
                    <el-checkbox-group v-model="unsubscribeForm.parts">
                      <el-checkbox
                        v-show="item.goodsTypeName == '配件' && item.productionState !== 10 && item.productionState !== 11 && item.productionState !== 12 && item.refundNotReturn !== '退款不退货'"
                        v-for="(item,index) in shoplist"
                        :data-goods="item.goodsId"
                        :key="index"
                        :label="item.id"
                        :value="item.id"
                        name="type"
                        style="width: 325px;word-break: break-all;word-wrap:break-word;white-space: inherit;"
                      >{{ item.goodsName }}(规格：{{ item.goodsSpecs }},价格：{{ (item.totalPrice/100).toFixed(2) }})</el-checkbox>
                    </el-checkbox-group>
                  </el-form-item>
                  <el-form-item label="退订原因" prop="unsubscribeReason">
                    <el-select v-model="unsubscribeForm.unsubscribeReason" placeholder="请选择退订原因">
                      <el-option
                        v-for="(item,index) in returnOrderReasonList"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="是否生产" prop="isProduction">
                    <el-select v-model="unsubscribeForm.isProduction" placeholder="请选择">
                      <el-option
                        v-for="(item,index) in whetherProduceList"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="蛋糕去向" prop="cakeWhereabouts">
                    <el-select v-model="unsubscribeForm.cakeWhereabouts" placeholder="请选择蛋糕去向">
                      <el-option
                        v-for="(item,index) in cakeWhereaboutsList"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="申请原因" prop="applyReason">
                    <el-input
                      type="textarea"
                      v-model.trim="unsubscribeForm.applyReason"
                      placeholder="请输入申请原因"
                      maxlength="50"
                      :autosize="{ minRows: 3 }"
                      style="width: 350px;"
                    ></el-input>
                  </el-form-item>
                  <el-form-item>
                    <el-button @click="unsubscribeResetForm('unsubscribeForm')">取消</el-button>
                    <el-button
                      :data-id="ruleForm.id"
                      type="primary"
                      @click="unsubscribeSubmitForm($event,'unsubscribeForm')"
                    >确定</el-button>
                  </el-form-item>
                </el-form>
              </div>
            </el-col>
          </el-col>
        </el-scrollbar>
      </div>
    </el-dialog>
    <!------------- 退款 --------------  -->
    <el-dialog
      title
      :visible.sync="refundOpenFlag"
      :before-close="refundFormClose"
      center
      :append-to-body="true"
      :lock-scroll="false"
      width="60%"
      z-index="2007"
    >
      <div style="width: 100%;height: 430px;">
        <el-scrollbar class="page-component__scroll" style="height: 400px;">
          <el-col style="margin-top: 1%;">
            <el-col style="margin-top: 1%;">
              <div class="order-message" style="height: 35px;">
                <el-col v-show="RefundShowFlag && RefundNoReShowFlag == false" style="padding-left: 5px;font-size: 20px;">退款</el-col>
                <el-col v-show="RefundNoReShowFlag && RefundShowFlag == false" style="padding-left: 5px;font-size: 20px;">退款不退货</el-col>
              </div>
              <div style="height: 300px;margin-left: 25px;">
                <el-form
                  :model="refundForm"
                  :rules="refundrules"
                  ref="refundForm"
                  label-width="100px"
                  class="demo-ruleForm"
                >
                  <el-form-item style="margin-left: -99px;">
                    <el-col class="formType">
                      <el-form-item label="后台单号">
                        <div style="width: 198px;">{{ ruleForm.xmbzNo }}</div>
                      </el-form-item>
                      <el-form-item label="是否生产" prop="isProduction">
                        <el-select v-model="refundForm.isProduction" placeholder="请选择">
                          <el-option
                            v-for="(item,index) in whetherProduceList"
                            :key="index"
                            :label="item.dictValue"
                            :value="item.dictKey"
                          ></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col v-if="refundCakeFlag" class="formType" style="margin-bottom: 30px;height: 100%;">
                      <el-form-item label="退款蛋糕">
                        <el-checkbox-group class="refundcake refundcakeFlag" v-model="refundForm.orderDetailIds" @change="getTotalprice">
                          <el-checkbox
                            v-for="(item,index) in refundList"
                            v-show="item.categoryName == '蛋糕'"
                            :key="index"
                            :label="item.id"
                            :value="item.id"
                            name="type"
                            :disabled="item.refundIdentification === '已退款'"
                            style="width: 325px;word-break: break-all;word-wrap:break-word;white-space: inherit;display: flex;"
                          >
                          <span>{{ item.goodsName }}(规格：{{ item.goodsSpecs }},价格：{{ (item.totalPrice/100).toFixed(2) }})</span>
                          <span class="el-col-primary dangerbutton" v-show="item.refundIdentification === '已退款'">已退款</span>
                          </el-checkbox>
                          <!-- <span>数量</span>
                          <span class="el-icon-remove-outline"></span>
                          <span>{{ 1 }}</span>
                          <span class="el-icon-circle-plus-outline"></span> -->
                        </el-checkbox-group>
                      </el-form-item>
                    </el-col>
                    <el-col v-if="customCakeFlag" class="formType" style="margin-bottom: 30px;height: 100%;">
                      <el-form-item label="定制蛋糕">
                        <el-checkbox-group class="refundcake refundcakeFlag" v-model="refundForm.customCake" @change="getCustomprice">
                          <el-checkbox
                            v-show="item.categoryName == '定制蛋糕'"
                            v-for="(item,index) in refundList"
                            :key="index"
                            :label="item.id"
                            :value="item.id"
                            :disabled="item.refundIdentification === '已退款'"
                            name="type"
                            style="width: 325px;word-break: break-all;word-wrap:break-word;white-space: inherit;"
                          >
                          <span>{{ item.goodsName }}(规格：{{ item.goodsSpecs }},价格：{{ (item.totalPrice/100).toFixed(2) }})</span>
                          <span class="el-col-primary dangerbutton" v-show="item.refundIdentification === '已退款'">已退款</span>
                          </el-checkbox>
                        </el-checkbox-group>
                      </el-form-item>
                    </el-col>
                    <el-col v-if="partsFlag" class="formType" style="height: 100%;">
                      <el-form-item label="配件">
                        <el-checkbox-group class="refundcake refundcakeFlag" v-model="refundForm.parts" @change="getPartsprice">
                          <el-checkbox
                            v-show="item.categoryName == '配件'"
                            v-for="(item,index) in refundList"
                            :key="index"
                            :label="item.id"
                            :value="item.id"
                            :disabled="item.refundIdentification === '已退款'"
                            name="type"
                            style="width: 325px;word-break: break-all;word-wrap:break-word;white-space: inherit;"
                          >
                          <span>{{ item.goodsName }}(规格：{{ item.goodsSpecs }},价格：{{ (item.totalPrice/100).toFixed(2) }})</span>
                          <span class="el-col-primary dangerbutton" v-show="item.refundIdentification === '已退款'">已退款</span>
                          </el-checkbox>
                        </el-checkbox-group>
                      </el-form-item>
                    </el-col>
                    <el-col class="formType">
                      <el-form-item label="退款原因" prop="refundReason">
                        <el-select v-model="refundForm.refundReason" placeholder="请选择退款原因">
                          <el-option
                            v-for="(item,index) in getRefundReasonList"
                            :key="index"
                            :label="item.dictValue"
                            :value="item.dictKey"
                          >
                            <span @click="refundReasonOpen(item.dictValue)" style="display: inline-block;width: 100%;">{{ item.dictValue }}</span>
                          </el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item label="蛋糕去向" prop="cakeWhereabouts">
                        <el-select v-model="refundForm.cakeWhereabouts" placeholder="请选择蛋糕去向">
                          <el-option
                            v-for="(item,index) in cakeWhereaboutsList"
                            :key="index"
                            :label="item.dictValue"
                            :value="item.dictKey"
                          ></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col class="formType">
                      <el-form-item label="退款类型" prop="refundType">
                        <el-select v-model="refundForm.refundType" placeholder="请选择退款类型">
                          <el-option
                            v-for="(item,index) in getRefundTypeList"
                            :key="index"
                            :label="item.dictValue"
                            :value="item.dictKey"
                          ></el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item label="退款等级" prop="refundGrade">
                        <el-select v-model="refundForm.refundGrade" placeholder="请选择退款等级">
                          <el-option
                            v-for="(item,index) in getRefundGradeList"
                            :key="index"
                            :label="item.dictValue"
                            :value="item.dictKey"
                          ></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <!-- <el-col class="formType">
                      <el-form-item label="退款方式" prop="refundMode">
                        <el-radio-group v-model="refundForm.refundMode">
                          <el-radio
                            v-for="(item,index) in radioList"
                            :key="index"
                            :label="item.dictKey"
                            :data-dictKey="item.dictKey"
                            @change="getRadio(item.dictKey)"
                          >
                          <span>{{ item.dictValue }}</span>
                          </el-radio>
                        </el-radio-group>
                      </el-form-item>
                    </el-col> -->
                    <!-- <el-col v-if="refundRadioFlag" class="formType"> -->
                    <el-col class="formType">
                      <el-form-item label="退款金额" prop="refundMoney">
                        <el-input
                          v-model.trim="refundForm.refundMoney"
                          placeholder="请输入金额"
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          maxlength="10"
                          show-word-limit
                          style="width: 200px;"
                        ></el-input>
                        <span style="moneyStyle">元</span>
                      </el-form-item>
                    </el-col>
                    <!-- <el-col v-if="payforRadioFlag" class="formType"> -->
                    <el-col class="formType">
                      <!-- <el-form-item label="赔偿方式" prop="compensationMethod"> -->
                      <el-form-item label="赔偿方式">
                        <el-radio-group v-model="refundForm.compensationMethod">
                          <!-- <el-radio label="退款"><span></span></el-radio> -->
                          <el-radio
                            v-for="(item,index) in getCompensationMethodList"
                            :key="index"
                            :label="item.dictKey"
                            @change="getcompensationMethodRadio(item.dictKey)"
                          >
                          <span>{{ item.dictValue }}</span>
                          </el-radio>
                        </el-radio-group>
                      </el-form-item>
                    </el-col>
                    <!-- <el-col v-if="compensationMethodFlag" style="margin-left: 50px;"> -->
                    <el-col style="margin-left: 50px;">
                      <el-form-item label="金额" label-width="80px" prop="" style="margin-bottom: 10px;margin-left: 20px;">
                        <el-input
                          v-model.trim="refundForm.cakeCompensatePrice"
                          placeholder="金额"
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          maxlength="10"
                          show-word-limit
                          style="width: 200px;"
                        ></el-input>
                        <span style="moneyStyle">元</span>
                      </el-form-item>
                      <el-form-item label="诚意金" style="line-height: 5;margin-top: 20px;">
                        <el-input
                          v-model="refundForm.sincerityGold"
                          placeholder="请输入诚意金"
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          maxlength="10"
                          show-word-limit
                          style="width: 200px;"
                        ></el-input>
                        <span style="moneyStyle">元</span>
                      </el-form-item>
                      <el-form-item label="赠送蛋糕" style="line-height: 5;margin-top: 20px;">
                        <el-input
                          v-model.number="refundForm.giveCakePrice"
                          placeholder="请输入金额"
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          maxlength="10"
                          show-word-limit
                          style="width: 200px;"
                        ></el-input>
                        <span style="moneyStyle">元</span>
                      </el-form-item>
                      <el-form-item label="赠送礼品" style="line-height: 5;margin-top: 20px;">
                        <el-input
                          v-model="refundForm.giveGiftPrice"
                          placeholder="请输入金额"
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          maxlength="10"
                          show-word-limit
                          style="width: 200px;"
                        ></el-input>
                        <span style="moneyStyle">元</span>
                      </el-form-item>
                    </el-col>
                    <el-col class="formType">
                      <el-form-item label="渠道">
                        <div style="width: 198px;">{{ ruleForm.channelName }}</div>
                      </el-form-item>
                    </el-col>
                  </el-form-item>
                  <el-form-item label="申请原因" prop="applyReason">
                    <el-input
                      type="textarea"
                      v-model.trim="refundForm.applyReason"
                      maxlength="50"
                      placeholder="请输入申请原因"
                      :autosize="{ minRows: 3 }"
                      style="width: 350px;"
                      show-word-limit
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="平台门店" prop="store">
                    <el-input
                      type="textarea"
                      v-model.trim="refundForm.store"
                      placeholder="请输入平台门店"
                      maxlength="30"
                      show-word-limit
                      autosize
                      style="width: 200px;"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="退款二维码">
                    <el-upload
                      list-type="picture-card"
                      action="/api/xmbz-goods/file/upload"
                      :data="{tag:'good'}"
                      :show-file-list="false"
                      :on-success="handleAvatarSuccess"
                      :on-preview="handlePictureCardPreview"
                      :on-remove="handleRemove"
                    >
                      <img
                        v-if="temp.mainPic&&temp.mainPic.length"
                        :src="temp.mainPic"
                        class="avatar"
                      />
                      <i v-else class="el-icon-plus"></i>
                    </el-upload>
                  </el-form-item>
                  <el-form-item>
                    <el-button @click="refundResetForm('refundForm')">取消</el-button>
                    <el-button
                      :data-id="ruleForm.id"
                      :data-platformOrderId="ruleForm.platformOrderId"
                      type="primary"
                      @click="refundSubmitForm($event,'refundForm')"
                    >申请退款</el-button>
                  </el-form-item>
                </el-form>
              </div>
            </el-col>
          </el-col>
        </el-scrollbar>
      </div>
    </el-dialog>
    <!------------- 恢复订单 --------------  -->
    <el-dialog
      title
      :visible.sync="recoverOrderFlag"
      center
      :append-to-body="true"
      :lock-scroll="false"
      width="420px"
      z-index="2007"
    >
      <div style="width: 100%;">
        <div class="order-message" style="height: 35px;border-bottom: 0">
          <el-col style="padding-left: 5px;font-size: 20px;">恢复订单</el-col>
        </div>
        <el-form
          :model="recoverForm"
          ref="recoverForm"
          label-width="100px"
          class="demo-ruleForm"
        >
          <!-- <el-form-item> -->
          <div style="font-size: 17px;margin-left: 5px;">您确认要恢复订单吗？</div>
          <!-- </el-form-item> -->
          <el-form-item style="margin-top: 7%;display: flex;justify-content: flex-end;">
            <el-button @click="recoverResetForm('recoverForm')">取消</el-button>
            <el-button
              type="primary"
              :data-id="ruleForm.id"
              @click="recoverSubmitForm($event,'recoverForm')"
            >确定</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-dialog>
    <!------------- 催单 --------------  -->
    <el-dialog
      title
      :visible.sync="reminderFlag"
      center
      :append-to-body="true"
      :lock-scroll="false"
      width="50%"
      z-index="2007"
    >
      <div style="width: 100%;height: 430px;">
        <el-scrollbar class="page-component__scroll" style="height: 400px;">
          <el-col style="margin-top: 1%;">
            <el-col style="margin-top: 1%;">
              <div class="order-message" style="height: 35px;">
                <el-col style="padding-left: 5px;font-size: 20px;">催单</el-col>
              </div>
              <div style="height: 300px;margin-left: 25px;">
                <el-form
                  :model="reminderForm"
                  :rules="reminderrules"
                  ref="reminderForm"
                  label-width="100px"
                  class="demo-ruleForm"
                >
                  <el-form-item label="催单类型" prop="reminderType" style="margin-bottom: 22px;">
                    <el-select v-model="reminderForm.reminderType" placeholder="请选择催单类型">
                      <el-option
                        v-for="(item,index) in reminderList"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="催单内容" prop="reminderContent">
                    <el-input
                      type="textarea"
                      v-model.trim="reminderForm.reminderContent"
                      placeholder="请输入催单内容"
                      :autosize="{ minRows: 3 }"
                      maxlength="50"
                      show-word-limit
                      style="width: 350px;"
                    ></el-input>
                  </el-form-item>
                  <el-form-item style="margin-top: 15%;">
                    <el-button @click="reminderResetForm('reminderForm')">取消</el-button>
                    <el-button
                      type="primary"
                      :data-id="ruleForm.id"
                      @click="reminderSubmitForm($event,'reminderForm')"
                    >提交</el-button>
                  </el-form-item>
                </el-form>
              </div>
            </el-col>
          </el-col>
        </el-scrollbar>
      </div>
    </el-dialog>
    <!------------- 备款 --------------  -->
    <el-dialog
      title
      :visible.sync="frmLossFlag"
      center
      :append-to-body="true"
      :lock-scroll="false"
      width="60%"
      z-index="2007"
    >
      <div style="width: 100%;min-height: 600px">
        <el-scrollbar class="page-component__scroll" style="height: 500px;">
          <el-col style="margin-top: 1%;">
            <el-col style="margin-top: 1%;">
              <div class="order-message" style="height: 35px;">
                <el-col style="padding-left: 5px;font-size: 20px;">备款</el-col>
              </div>
              <div style="height: 300px;margin-left: 25px;">
                <el-form
                  :model="frmLossForm"
                  :rules="frmLossrules"
                  ref="frmLossForm"
                  label-width="100px"
                  class="demo-ruleForm"
                >
                  <el-form-item label="后台单号">
                    <div>{{ ruleForm.xmbzNo }}</div>
                  </el-form-item>
                  <el-form-item label="备款来源" prop="provisionsOperation">
                    <el-select
                      v-model="frmLossForm.provisionsOperation"
                      placeholder="请选择备款来源"
                      @input="idProvisionsOperation()"
                    >
                      <el-option
                        v-for="(item,index) in getSourceList"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item v-show="refundCakeFlag" label="备款蛋糕" style="height: 100%;">
                    <el-checkbox-group class="refundcake" v-model="frmLossForm.orderDetailIds">
                      <el-checkbox
                        v-for="(item,index) in shoplist"
                        v-show="item.goodsTypeName == '蛋糕' && item.productionState !== 10 && item.productionState !== 11"
                        :key="index"
                        :label="item.id"
                        :value="item.id"
                        name="type"
                        style="width: 325px;word-break: break-all;word-wrap:break-word;white-space: inherit;display: flex;margin-top: 15px;"
                      >{{ item.goodsName }}(规格：{{ item.goodsSpecs }},价格：{{ item.originalPrice }})</el-checkbox>
                    </el-checkbox-group>
                  </el-form-item>
                  <el-form-item label="责任部门" prop="personDept" style="margin-top: 8px;">
                    <el-select v-model="frmLossForm.personDept" placeholder="请选择部门">
                      <el-option
                        v-for="(item,index) in frmLossList"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="责任人" prop="personLiable">
                    <el-input
                      v-model.trim="frmLossForm.personLiable"
                      placeholder="请输入责任人"
                      maxlength="10"
                      show-word-limit
                      style="width: 200px;"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="蛋糕去向" prop="cakeWhereabouts">
                    <el-select v-model="frmLossForm.cakeWhereabouts" placeholder="请选择蛋糕去向">
                      <el-option
                        v-for="(item,index) in cakeWhereaboutsList"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="备款内容" prop="provisionsContent">
                    <el-input
                      type="textarea"
                      v-model.trim="frmLossForm.provisionsContent"
                      :autosize="{ minRows: 3 }"
                      maxlength="50"
                      show-word-limit
                      style="width: 350px;"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="是否生产" prop="isProduction">
                    <el-select v-model="frmLossForm.isProduction" placeholder="请选择">
                      <el-option
                        v-for="(item,index) in whetherProduceList"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item v-show="!frmLossTimeFlag" class="Star-beacon" label="退订原因">
                    <el-select v-model="frmLossForm.unsubscribeReason" placeholder="请选择退款原因">
                      <el-option
                        v-for="(item,index) in returnOrderReasonList"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item v-show="!frmLossTimeFlag" class="Star-beacon" label="申请原因">
                    <el-input
                      type="textarea"
                      v-model.trim="frmLossForm.applyReason"
                      placeholder="请输入申请原因"
                      :autosize="{ minRows: 3 }"
                      maxlength="50"
                      show-word-limit
                      style="width: 350px;"
                    ></el-input>
                  </el-form-item>
                  <!-- <el-form-item v-show="frmLossTimeFlag" label="配送时间" class="el-form-item-class">
                    <el-button type="primary" plain @click="deliveryTimeOpen">选择配送时间</el-button>
                  </el-form-item> -->
                  <el-form-item v-show="frmLossTimeFlag" label="配送时间" class="el-form-item-class Star-beacon">
                    <div style="display: flex;margin-left: -10px;">
                      <el-date-picker
                        type="date"
                        size="medium"
                        :placeholder="getdelOrderStartTime"
                        v-model="getdeliveryStartTime"
                        :picker-options="pickerOptionsStart"
                        value-format="yyyy-MM-dd "
                        format="yyyy-MM-dd "
                        :disabled="orderStatus == 8 || ruleForm.receivedTime !== ''"
                        :clearable="false"
                        style="width: 170px;margin: 0 0 0 10px;"
                      ></el-date-picker>
                      <div class="line" :span="1" style="margin:  0 10px;">-</div>
                      <selecttime
                        ref="getdeliveryTime"
                        v-bind:deliveryTime="getdeliveryStartTime"
                        v-bind:OrderStartTime="ruleForm.deliveryStartTime"
                        v-bind:OrderEndTime="ruleForm.deliveryEndTime"
                        v-bind:OrderTimeFlag="OrderTimeFlag"
                        v-bind:Orderstatus="ruleForm.status"
                        v-bind:receivedTime="ruleForm.receivedTime"
                        style="width: 170px;margin: 0"
                      ></selecttime>
                    </div>
                  </el-form-item>
                  <el-form-item>
                    <el-button @click="frmLossResetForm('frmLossForm')">取消</el-button>
                    <el-button
                      :data-id="ruleForm.id"
                      :data-orderId="ruleForm.orderId"
                      type="primary"
                      @click="frmLossSubmitForm($event,'frmLossForm')"
                    >提交</el-button>
                  </el-form-item>
                </el-form>
              </div>
            </el-col>
          </el-col>
        </el-scrollbar>
      </div>
    </el-dialog>
    <!------------- 投诉 --------------  -->
    <el-dialog
      title
      :visible.sync="complainFlag"
      center
      :append-to-body="true"
      :lock-scroll="false"
      width="50%"
      z-index="2007"
    >
      <div style="width: 100%;height: 430px;">
        <el-scrollbar class="page-component__scroll" style="height: 400px;">
          <el-col style="margin-top: 1%;">
            <el-col style="margin-top: 1%;">
              <div class="order-message" style="height: 35px;">
                <el-col style="padding-left: 5px;font-size: 20px;">投诉操作</el-col>
              </div>
              <div style="height: 300px;margin-left: 25px;">
                <el-form
                  :model="complainForm"
                  :rules="complainrules"
                  ref="complainForm"
                  label-width="100px"
                  class="demo-ruleForm"
                >
                  <el-form-item label="投诉等级" prop="complaintLevel">
                    <el-select v-model="complainForm.complaintLevel" placeholder="请选择投诉等级">
                      <el-option
                        v-for="(item,index) in getComplaintLevelList"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="投诉渠道" prop="complaintChannel">
                    <el-select v-model="complainForm.complaintChannel" placeholder="请选择投诉渠道">
                      <el-option
                        v-for="(item,index) in getComplaintChannelList"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="投诉内容" prop="complaintContent">
                    <el-input
                      type="textarea"
                      v-model.trim="complainForm.complaintContent"
                      placeholder="请输入投诉内容"
                      :autosize="{ minRows: 3 }"
                      maxlength="200"
                      show-word-limit
                      style="width: 350px;"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="手机号码" prop="phone">
                    <el-input
                      v-model.number="complainForm.phone"
                      placeholder="请输入号码"
                      maxlength="11"
                      @keydown.native="channelFilter"
                      show-word-limit
                      style="width: 200px;"
                    ></el-input>
                  </el-form-item>
                  <el-form-item style="margin-top: 15%;">
                    <el-button @click="complainResetForm('complainForm')">取消</el-button>
                    <el-button
                      type="primary"
                      :data-id="ruleForm.id"
                      @click="complainSubmitForm($event,'complainForm')"
                    >提交</el-button>
                  </el-form-item>
                </el-form>
              </div>
            </el-col>
          </el-col>
        </el-scrollbar>
      </div>
    </el-dialog>
    <!------------- 编辑商品 --------------  -->
    <el-dialog
      title
      :visible.sync="openEditCakeFlag"
      :before-close="handleCakeClose"
      center
      :append-to-body="true"
      :lock-scroll="false"
      width="70%"
      z-index="2007"
    >
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="商品" name="first">
          <el-col style="margin-top: 1%;">
            <div class="order-message" style="height: 35px;width: 100%;">
              <el-col :span="10">
                <el-input v-model="cakeInput" clearable placeholder="请输入商品名称" size="small"></el-input>
              </el-col>
              <el-col :span="5" style="margin-left: 15px;">
                <el-button icon="el-icon-search" type="primary" size="small" @click="open()">查询</el-button>
              </el-col>
            </div>
            <el-scrollbar class="page-component__scroll" v-loading="Loading" style="width: 100%;height: 600px;">
              <div v-for="(item, index) in list" :key="index" class="order-list">
                <div class="order-list-item">
                  <div class="orderdetail-header-area">
                    <div class="order-header" style="display: flex;justify-content: space-between;">
                      <div class="order-num">
                        <span>{{ item.name }}</span>
                        <i></i>
                      </div>
                      <div class="order-state"></div>
                      <el-tag type="danger" style="margin-right: 50%;">{{ item.categoryName }}</el-tag>
                    </div>
                  </div>
                  <div class="order-user-area" style="display: flex">
                    <div style="width: 100px;height: 80px;margin-right: 10px;">
                      <img style="width: 100px;height: 80px;" :src="item.mainPic" alt="">
                    </div>
                    <div style="margin-left: 10px;width: 86%;">
                      <div class="user-phone-address">
                        <div style="display: flex;">
                          <el-col style="width: 75%">
                            <h3 style="margin: 0 0 9px 0;padding-bottom: 5px;border-bottom: 1px solid #C0C4CC;width: 70px;text-align: center;">规格</h3>
                            <div
                              v-for="(cakeing,key) in item.goodsSkuVOS"
                              :key="key"
                              style="margin-bottom: 5px;"
                            >
                              <el-button
                                :data-id="cakeing.id"
                                @click="choiceCheck(cakeing,index,$event)"
                              >{{ cakeing.specs }}</el-button>
                            </div>
                          </el-col>
                          <el-col style="width: 25%">
                            <h3 style="margin: 0 0 9px 0;padding-bottom: 5px;border-bottom: 1px solid #C0C4CC;width: 70px;text-align: center;">价格</h3>
                            <div
                              v-for="(cakeing,key) in item.goodsSkuVOS"
                              :key="key"
                              style="line-height: 40px;margin-bottom: 5px;"
                            >
                              <span
                                style="display: inline-block;text-align: center;"
                              ><i class="price-style" style="color: red;margin-right: 5px;">{{ (cakeing.price/100).toFixed(2) }}</i>元</span>
                            </div>
                          </el-col>
                        </div>
                        <el-button type="primary" @click="addEditCake(item)">添加</el-button>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <pagination v-show="shopTotal>0" :total="shopTotal" :page.sync="productList.page" :limit.sync="productList.size"
                @pagination="getCakeList" />
              <!-- <el-pagination
                background
                :current-page.sync="currentPage"
                layout="prev, pager, next, sizes, total, jumper"
                :page-sizes="[5, 10, 15, 20]"
                :page-size.sync="pagesize"
                :total="list.length"
                @current-change="handleCurrentChange"
                @size-change="handleSizeChange"
                style="margin-top: 5px 0;"
              >
              </el-pagination> -->
            </el-scrollbar>
          </el-col>
        </el-tab-pane>
        <el-tab-pane label="备款蛋糕" name="second">
          <el-col style="margin-top: 1%;">
            <div class="order-message" style="width: 100%;height: 35px;">
              <el-col :span="10">
                <el-input v-model="input" clearable placeholder="请输入蛋糕名称" size="small"></el-input>
              </el-col>
              <el-col :span="5" style="margin-left: 15px;">
                <el-button icon="el-icon-search" type="primary" size="small" @click="ProvisionsGoodsPageopen()">查询</el-button>
              </el-col>
            </div>
            <el-scrollbar class="page-component__scroll" style="width: 100%;height: 600px;">
              <div v-loading="Loading" v-for="(cakeMessage, index) in getGoodsPageList" :key="index" class="order-list">
                <div class="order-list-item">
                  <div class="orderdetail-header-area" style="padding-top: 10px;">
                    <div class="order-header">
                      <div class="order-num" style="width: fit-content;">
                        <span>{{ cakeMessage.goodsName }}</span>
                        <!-- <i></i> -->
                      </div>
                      <div class="order-state"></div>
                    </div>
                  </div>
                  <div class="order-user-area" style="display: flex">
                    <div style="margin-left: 10px;width: 100%;">
                      <div class="user-phone-address">
                        <div style="display: flex;">
                          <el-col style="width: 65%">
                            <p class="phone-title">蛋糕旧单号：<span style="color: #000">{{ cakeMessage.xmbzNo }}</span></p>
                            <p class="phone-title">蛋糕明细编码：<span style="color: #000">{{ cakeMessage.orderDetailId }}</span></p>
                            <p class="phone-title">规格：<span style="color: #000">{{ cakeMessage.goodsSpecs }}</span></p>
                            <div style="display: flex;justify-content: space-between;">
                              <p class="phone-title">价格：<i class="price-style">{{ (cakeMessage.cakePrice/100).toFixed(2) }}</i></p>
                              <p class="phone-title">数量：<span style="color: #000">{{ cakeMessage.cakeNum }}</span></p>
                            </div>
                            <div style="display: flex;justify-content: space-between;">
                              <p class="phone-title">城市：<span style="color: #000">{{ cakeMessage.cityName }}</span></p>
                              <p class="phone-title">总仓：<span style="color: #000">{{ cakeMessage.mainWarehouse }}</span></p>
                              <p class="phone-title">分仓：<span style="color: #000">{{ cakeMessage.branchWarehouse }}</span></p>
                            </div>
                          </el-col>
                        </div>
                        <div style="display: flex;justify-content: flex-end;margin-right: 50px;">
                          <el-button type="primary" @click="choiceGoodsCheck(cakeMessage)">添加</el-button>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <pagination v-show="GoodsPageTotal>0" :total="GoodsPageTotal" :page.sync="getProvisionsGoodsPageQuery.page" :limit.sync="getProvisionsGoodsPageQuery.size"
                @pagination="getProvisionsGoodsPageList" />
            </el-scrollbar>
          </el-col>
        </el-tab-pane>
        <el-tab-pane label="已选商品" name="third">
          <el-col style="margin-top: 1%;">
            <el-scrollbar class="page-component__scroll" style="height: 600px;">
              <div>
                <table v-for="(value,index) in tableData" :key="index" style="margin-bottom: 20px;width: 98%;" class="order-list">
                  <tr>
                    <td>商品名称</td>
                    <td>商品规格</td>
                    <td>价格</td>
                    <td>现价</td>
                    <td>商品数量</td>
                  </tr>
                  <tr>
                    <td style="width: 8rem;">{{ value.goodsName }}</td>
                    <td style="width: 6rem;">{{ value.specs }}</td>
                    <td style="width: 4rem;">{{ (value.price/100).toFixed(2) }}</td>
                    <td style="width: 4rem;">{{ (value.price/100).toFixed(2) }}</td>
                    <td style="width: 14rem;">
                      <!-- <el-button
                        size="mini"
                        @click="handleEdit(index,$event)"
                      >添加</el-button> -->
                      <span style="width: 40px;display: inline-block;">{{ value.num }}</span>
                      <!-- <el-button
                        size="mini"
                        type="danger"
                        @click="handleDelete(index,$event)"
                      >减少</el-button> -->
                    </td>
                  </tr>
                  <tr>
                    <td colspan="4">
                      <p style="color: red;font-size: 15px;font-weight: 600;">祝福语</p>
                      <el-input v-model.trim="value.blessings" maxlength="16" type="textarea" placeholder="请输入祝福语" class="orderspecial" show-word-limit autosize></el-input>
                    </td>
                    <td style="color: red;font-size: 15px;font-weight: 600;">
                      <div style="display: flex;justify-content: space-around;line-height: 2;">
                        总价：<span id="singletonPrice">{{ (value.getPrice/100).toFixed(2) }}</span>
                        <el-button size="small" @click="cleanOrder(index,$event)">清除</el-button>
                      </div>
                    </td>
                  </tr>
                </table>
                <div style="display: flex;flex-direction: column;align-items: flex-end;">
                  <p style="color: red;font-size: 20px;font-weight: 700;margin-right: 20px;">所选商品总价：{{ (sumPrice/100).toFixed(2) }}</p>
                </div>
                <el-col style="display: flex;flex-direction: column;align-items: flex-end;">
                  <el-button type="primary" @click="onAddSumbit(sumPrice)" style="margin-right: 20px;">提交</el-button>
                </el-col>
              </div>
            </el-scrollbar>
          </el-col>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>
    <!-- 图片弹框 -->
    <el-dialog
      title
      :visible.sync="imgFlag"
      center
      :append-to-body="true"
      :lock-scroll="false"
      width="80%"
      z-index="2007"
    >
      <div style="width: 100%;">
        <el-scrollbar class="page-component__scroll">
          <el-col>
            <img :src="ruleForm.groupBuyQRCode" alt="" width="100%" height="100%">
          </el-col>
        </el-scrollbar>
      </div>
    </el-dialog>
  </div>
</template>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=57358ac872e8f834962f8aa7072c7bfe&plugin=AMap.Autocomplete,AMap.PlaceSearch"></script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=57358ac872e8f834962f8aa7072c7bfe&plugin=AMap.Autocomplete"></script>
<script src="http://webapi.amap.com/maps?v=1.4.0&key=57358ac872e8f834962f8aa7072c7bfe&plugin=AMap.Geocoder"></script>

<script>
import {
  orderList, // 查询
  detailList,// 订单详情
  getResponsibleDepartmentList, // 备款责任部门
  getCakeWhereaboutsList, // 蛋糕去向
  getProvisionsOperationList, // 备款来源
  addWorkOrderProvisions, // 新增备款（选择退订）
  getUnsubscribeReasonList, // 退订原因列表
  getIsProductionList, // 是否生产
  addWorkOrderUnsubscribe, // 新增退订
  getRefundGradeList, // 退款等级列表
  getRefundReasonList, // 退款原因列表
  getRefundTypeList, // 退款类型列表
  getFullRefundList, // 全额退款列表
  getCompensationMethodList, // 赔偿方式列表
  getRefundModeList, // 退款方式列表
  addWorkOrderRefund, // 新增退款
  addRefundNotReturn, // 新增退款不退货
  getRecoveryOrder, // 恢复订单
  // getOrderOperateLog, // 订单日志
  getComplaintLevelList, // 投诉等级列表
  getComplaintChannelList, // 投诉渠道列表
  addWorkOrderComplaint, // 新增投诉
  getReminderTypeList, // 催单类型列表
  addWorkOrderReminder, // 新增催单
  updateByProvisions, // 修改订单状态
  updateList,// 确认订单
  getCategories,// 商品类型列表
  refundUnsubscribeConfirmOrder, // 退订退款请求修改
  getGoodsByOrderId, // 根据订单号,查询商品列表(退款)
  deleteOrderExt, // 平台退款中
  orderSubmitGoodsTime, // 编辑订单里面商品的提交时间
} from '@/api/pending';
import {
  citySelect,// 城市
  getOrderChannelList,// 渠道
  getOrderChannelTypeList, // 渠道类别列表
  getSurplusWarehouseLoadList, // 仓库剩余负荷列表
  getMainWarehouseList, // 获取分仓
  getSeparateWarehouseList, // 获取分仓
  getWarehouseName, // 根据经度纬度，返回分仓总仓名称
  getProvisionsGoodsPage, // 备款商品分页列表
  shopList, // 蛋糕商品列表
  judgeGoodsClose, // 判断当前商品是否关闭
} from '@/api/createOrder';
import { getWarehouseList } from "@/api/warehouse";
import { getUrlKey } from '@/util/getUrlKey.js';
import deliveryTime from '@/components/foundorder/deliverytime';
import DetailMap from '@/components/order-detail/map';
import Pagination from "@/components/Pagination"; // 分页
import selecttime from "@/components/foundorder/selecttime"; // 配送时间组件
export default {
  components: {
    DetailMap,
    deliveryTime,
    Pagination,
    selecttime,
  },
  data() {
    let checkPhone = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("号码不能为空"));
      }
      var reg = /^1[3456789]\d{9}$/;
      setTimeout(() => {
        if (!Number.isInteger(value)) {
          callback(new Error("请输入数字值"));
        } else if (value.toString().length !== 11) {
          callback(new Error("号码长度应为11位"));
        } else if (!reg.test(value)) {
          callback(new Error("手机号码格式有误"));
        } else {
          callback();
        }
      }, 1000);
    };
    let receiverAddress = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("地址不能为空"));
      } else {
        this.ruleForm.receiverAddress = value.replace(/\s+/g, '');
        callback();
      }
    };
    var checkData = (rule, value, callback) => {
      if (value) {
        if (/[\u4E00-\u9FA5]/g.test(value)) {
          this.ruleForm.sumPrice = '';
          callback(new Error('编码不能输入汉字!'));
        } else {
          callback();
        }
      }
      callback();
    };
    return {
      // xmbzNo:'',
      querydetail: {
        orderId: ''
      },
      shoplist: '',
      shopslist: '',
      closelist: '',
      shopcloselist: '',
      deptId: getUrlKey('cityId') !== 1 ? getUrlKey('cityId') : '',
      deptIdFlag: false,
      deptName: getUrlKey('deptName') !== '全国' ? getUrlKey('deptName') : '',
      // orderlist: '',
      cityselect: "", // 城市获取列表
      formInline: {
        deptId: getUrlKey('cityId'),// 城市id
        // xmbzNo: '',// 后台单号
        id: '',
        StartTime: '',
        EndTime: '',
        channelType: '',
        orderTimeSort: 0, // 下单时间排序
        deliveryTimeSort: 0, // 配送时间排序
        page: 1,
        limit: 10,
        size: 10,
        orderDetailRequests: []
      },
      orderStartEndTime: '',
      PendingStartTime: '',
      PendingEndTime: '',
      end: '',
      ruleForm: {
        totalPrice: '',
        channel: '',
        receiverDetailAddress: '',
        channelType: '',
        // wareHouse: '', // 用来获取分仓的参数
        branchWarehouse: '', // 分仓
        orderDetailRequests: []
      },
      rules: {
        channelType: [
          { required: true, message: '请选择渠道类型', trigger: 'blur' }
        ],
        channel: [
          { required: true, message: '请选择渠道', trigger: 'blur' }
        ],
        totalPrice: [
          { required: true, message: '请输入价格', trigger: 'blur' },
          { validator: checkData, trigger: 'change'}
        ],
        receiverName: [
          { required: true, message: '请输入收货人', trigger: 'blur' }
        ],
        receiverPhone: [
          { required: true, message: '请输入电话号码', trigger: 'blur' }
        ],
        mainWarehouse: [
          { required: true, message: '请选择仓库', trigger: 'blur' }
        ],
        branchWarehouse: [
          { required: true, message: '请选择仓库', trigger: 'blur' }
        ],
        receiverAddress: [{ required: true, validator: receiverAddress, trigger: "change" }]
      },
      updateByProvisionsList: { // 修改订单状态列表
        orderId: '',
        workOrderProvisionsIds: []
      },
      channerllist: '', //渠道
      selectdelitimeFlag: false, // 运力紧张警告，当配送时间已改变时，运力紧张标记去掉
      deliveryTimeUpdateFlag: false, // 配送时间Flag
      addressFlagcopy: false,// 地址列表
      isaddressFlagcopy: false,// 地址列表
      addressList: '',
      currentIndex: '',// 选中对应的索引
      getAreaScope: '',
      mapCenter: [121.59996, 31.197646],
      markers: [
        [121.59996, 31.197646],
        [121.40018, 31.197622],
        [121.69991, 31.207649]
      ],
      markersCopy: [], // 全国 未分配城市订单
      pagesize: 5,
      currentPage: 1,
      detailLoading: true,
      channelTypellist: '', // 渠道类别列表
      getChannelList: { // 渠道列表
        parentId: ''
      },
      getSurplusWarehouseLoadQuery: { // 仓库剩余负荷列表
        warehouseId: '',
        // warehouseDeliveryDate: ''
      },
      checkedlist: [],// 配送时间选择的时间的checked
      idList: [],
      timelist: [], // 负荷时间点
      warehouseLoadList: [], // 负荷数量
      getAreaScopeArray: [],
      overlayGroups: [],// 城市的所有仓
      citylist: "", // 下单仓库中的总仓
      abbrlist: "", // 分仓
      getMainWarehouseList: {
        parentId: ''
      },
      // 分仓
      getSeparateWarehouseList: {
        deptId: 1
      },
      getWarehousesByDeptIds: { // 查询所有仓库信息，划区域
        cityId: '',
        deptId: '',
        name: ''
      },
      getWarehouseName: {  // 根据经度纬度，返回分仓总仓名称
        longitude: 1,
        latitude: 2
      },
      journalFlag: false, // 确认订单按钮按钮
      returnOrderFlag: false, // 退订按钮
      refundMoneyFlag: false, // 退款按钮
      reminderOrderFlag: false, // 催单按钮
      frmLossOrderFlag: false, // 备款按钮
      complainOrderFlag: false, // 投诉按钮
      orderFlag: false, //恢复订单
      returnGoodsFlag: false, // 退订Flag
      refundCakeFlag: false,
      customCakeFlag: false, // 定制蛋糕
      partsFlag: false, // 配件
      returnOrderReasonList: "", //退订原因列表
      whetherProduceList: "", //是否生产列表
      cakeWhereaboutsList: "", //蛋糕去向列表
      refundReaList: {
        // 退款类型请求列表
        name: ""
      },
      // 退订
      unsubscribeForm: {
        orderId: 1,
        orderDetailIds: [],//xiangqign id
        customCake: [], // 定制蛋糕
        parts: [], // 配件
        selectOrderDetailIds: [], // 选中的订单明细id的集合
        noSelectOrderDetailIds: [], // 初始未选择的订单明细id的集合
        unsubscribeReason: "",
        isProduction: "",
        cakeWhereabouts: "", // 蛋糕去向
        applyReason: "" // 申请原因
      },
      unsubscribefRules: {
        unsubscribeReason: [
          { required: true, message: "请选择退订原因", trigger: "blur" }
        ],
        isProduction: [
          { required: true, message: "请选择生产状态", trigger: "change" }
        ],
        applyReason: [
          { required: true, message: "请输入申请原因", trigger: "change" }
        ],
        cakeWhereabouts: [
          { required: true, message: "请选择蛋糕去向", trigger: "change" }
        ],
        orderDetailIds: [
          {
            required: true,
            message: "请至少选择一个蛋糕",
            trigger: "change"
          }
        ],
      },
      refundOpenFlag: false, // 退款Flag
      refundCakePrice: '', // 所选中的退款蛋糕的总价
      refundRadioFlag: true, // 退款金额标记
      payforRadioFlag: false, // 赔偿方式中赔偿的标记
      compensationMethodFlag: false, // 赔偿方式标记
      getRefundGradeList: "", // 退款等级列表
      getRefundReasonList: "", // 退款原因列表
      getRefundTypeList: "", // 退款类型列表
      getCompensationMethodList: "", // 赔偿方式列表
      temp: {
        name: "",
        categoryId: "",
        mainPic: "",
        description: "",
        goodsSkuRequests: [],
        pics: []
      },
      radioList: [ // 退款方式
        {
          dictKey: 1,
          dictValue: '退款'
        },
        {
          dictKey: 2,
          dictValue: '赔偿'
        }
      ],
      refundForm: {
        // 退款
        orderId: 1, // 订单
        orderDetailIds: [], // 订单明细id的集合
        customCake: [], // 定制蛋糕
        parts: [], // 配件
        // platformNo: "", // 平台单号
        refundReason: "", // 退款原因
        // channel: "", // 退款渠道
        isProduction: "", // 是否生产
        cakeWhereabouts: "", // 蛋糕去向
        refundType: "", // 退款类型
        refundGrade: 1, // 退款等级
        // fullRefund: "", // 全额退款
        refundMoney: "", // 退款金额
        sincerityGold: "", // 诚意金
        compensationMethod: '', // 赔偿方式
        cakeCompensatePrice: 0, // 赔偿中的金额
        // typeKind: [],
        applyReason: "", // 申请原因
        refundCode: "", // 退款二维码
        store: "", // store
        refundMode: '', // 退款方式 1:退款 2:赔偿:refundMode
        giveCakePrice: '', // 赠送的蛋糕价格
        giveGiftPrice: '', // 赠送的礼品价格
      },
      refundrules: {
        refundReason: [
          { required: true, message: "请选择退款原因", trigger: "change" }
        ],
        isProduction: [
          { required: true, message: "请选择生产状态", trigger: "change" }
        ],
        cakeWhereabouts: [
          { required: true, message: "请选择蛋糕去向", trigger: "change" }
        ],
        refundType: [
          { required: true, message: "请输入退款类型", trigger: "change" }
        ],
        refundGrade: [
          { required: true, message: "请输入退款等级", trigger: "change" }
        ],
        // fullRefund: [
        //   { required: true, message: "请选择全额退款", trigger: "change" }
        // ],
        refundMoney: [
          { required: true, message: "金额不能为空" }
        ],
        sincerityGold: [
          { required: true, message: "金额不能为空" },
          { type: "number", message: "金额必须为数字值" }
        ],
        applyReason: [
          { required: true, message: "请输入申请原因", trigger: "change" }
        ],
        compensationMethod: [
          {
            required: true,
            message: "请至少选择一个赔偿方式",
            trigger: "change"
          }
        ],
        store: [
          { required: true, message: "请输入平台门店", trigger: "change" }
        ],
        refundCode: [
          { required: true, message: "请上传二维码", trigger: "change" }
        ],
        refundMode: [
          { required: true, message: '请选择活动资源', trigger: 'change' }
        ],
        orderDetailIds: [
          {
            required: true,
            message: "请至少选择一个蛋糕",
            trigger: "change"
          }
        ],
      },
      recoverOrderFlag: false, // 恢复订单
      recoverForm: {// 恢复订单
        orderId: 132
      },
      reminderFlag: false, //催单
      // 催单
      reminderForm: {
        orderId: '',
        reminderType: "", // 催单类型
        reminderContent: "" // 催单内容
      },
      reminderList: "", // 催单列表
      reminderrules: {
        reminderType: [
          { required: true, message: "请选择催单类型", trigger: "change" }
        ],
        reminderContent: [
          { required: true, message: "请输入催单内容", trigger: "change" }
        ]
      },
      // 日期
      pickerOptionsStart: {
        disabledDate: time => {
          let yy = new Date().getFullYear();
          let mm = new Date().getMonth() + 1< 10? "0" + (new Date().getMonth() + 1): (new Date().getMonth() + 1);
          let dd = new Date().getDate();
          let nowHours = new Date().getHours() < 10? "0" + new Date().getHours() : new Date().getHours();
          const nowDate = yy + "-" + mm + "-" + dd + ' ';
          this.nowHours = nowHours
          if(nowDate) {
            if(this.ruleForm.deliveryStartTime === nowDate) {
              // console.log(parseInt(nowHours) + parseInt(1)+':00')
              this.condition = true
            } else {
              this.condition = false
            }
          }
          return time.getTime() < Date.now() - 8.64e7;
        }
      },
      frmLossFlag: false, //备款
      frmLossList: "", // 备款责任部门列表
      getSourceList: "", // 备款来源列表
      frmLossTimeFlag: false, //备款（配送时间）按钮
      frmLossForm: {
        orderId: 1, //后台单号
        orderDetailIds: [], // 详情id
        personDept: "", //部门
        personLiable: "", //责任人
        cakeWhereabouts: "", //蛋糕去向
        provisionsContent: "", //备款内容
        provisionsOperation: "", //备款来源
        distributionStartTime: "", //配送时间
        distributionEndTime: "",//
        isProduction: "", // 是否生产
        // applyReason: "", // 申请原因
        // unsubscribeReason: "", // 退订原因
      },
      frmLossrules: {
        personDept: [
          { required: true, message: "请选择责任部门", trigger: "change" }
        ],
        personLiable: [
          { required: true, message: "请输入责任人", trigger: "change" }
        ],
        cakeWhereabouts: [
          { required: true, message: "请选择去向", trigger: "change" }
        ],
        provisionsContent: [
          { required: true, message: "请输入备款内容", trigger: "change" }
        ],
        isProduction: [
          { required: true, message: "请选择生产状态", trigger: "change" }
        ],
        provisionsOperation: [
          { required: true, message: "请输入备款来源", trigger: "change" }
        ],
        applyReason: [
          { required: true, message: "请输入申请原因", trigger: "change" }
        ],
        unsubscribeReason: [
          { required: true, message: "请选择退订原因", trigger: "change" }
        ],
        orderDetailIds: [
          {
            required: true,
            message: "请至少选择一个蛋糕",
            trigger: "change"
          }
        ],
      },
      complainFlag: false, //投诉
      getComplaintLevelList: "", // 投诉等级列表
      getComplaintChannelList: "", // 投诉渠道列表
      complainForm: {
        // 投诉
        orderId: "", // 后台单号
        phone: "", // 投诉号码
        responsibleDepartment: '', // 投诉责任部门
        departmentErrorType: '', // 部门失误类型
        complaintLevel: "", // 投诉等级
        complaintChannel: "", // 投诉渠道
        complaintContent: "" // 投诉内容
      },
      complainrules: {
        // 投诉
        complaintLevel: [
          { required: true, message: "请选择投诉等级", trigger: "blur" }
        ],
        complaintChannel: [
          { required: true, message: "请选择投诉渠道", trigger: "change" }
        ],
        complaintContent: [
          { required: true, message: "请输入投诉内容", trigger: "change" }
        ],
        phone: [{ required: true, validator: checkPhone, trigger: "change" }],
      },
      reverse: false,
      dayMessFlag: false, //订单日志
      openEditCakeFlag: false, // 编辑蛋糕列表弹窗
      noEditCakeFlag: true, // 未添加蛋糕时，无蛋糕商品显示
      getGoodsPageList: '', // 备款商品分页列表
      activeName: 'first', // 标签页
      input: "", // 备款蛋糕
      cakeInput: '', // 查询蛋糕
      list: "", // 蛋糕列表
      cakeinglist: {
        num: 1
      },
      tableData: [], // 已选蛋糕列表
      cakelist: '', // 点击添加蛋糕前，将点击的规格的数据传给cakelist
      sumPrice: 0, // 蛋糕总价
      getProvisionsGoodsPageQuery: { // 备款商品分页列表(请求)
        goodsName: '',
        page: 1,
        size: 10,
        cityId: '', //组织架构ID
      },
      productList: { // 蛋糕编辑列表
        deptId: '',
        page: 1,
        size: 10
      },
      judgeGoodsCloseQuery: { // 判断当前商品是否关闭请求
        warehouseId: '', // 仓库id
        skuCode: '', // sku码
      },
      getCategoriesList: [],//商品类型列表
      categoryId: [], //商品类型列表
      UnsubscribeFlag: false, // 退订标记
      refundFlag: false, // 退款标记
      getdeliverytimeFlag: false, // 客户选的时间
      shopTotal: 0, // 蛋糕分页
      GoodsPageTotal: 0, // 备款分页
      Loading: true,
      deliveryStart: '',
      deliveryEnd: '',
      latitude: '',
      longitude: '',
      latitudeFlag: false,
      addressCopyname: '',
      deliveryTimeNotes: '', //配送时间不能更改
      deliveryTimeEndNotes: '', //配送时间不能更改
      orderStatus: '',
      preservationFlag: false, // 保存信息
      RefundNoReFlag: false, // 退款不退货标记
      RefundShowFlag: false, // 退款请求接口标记
      RefundNoReShowFlag: false, // 退款不退货请求接口标记
      getdeliveryStartTime: '', // 时间
      getdelOrderStartTime: '', //订单时间
      OrderTimeFlag: true, // 订单标记
      getDeliveryFlag: false, // 订单时间是否过期标记
      refundList: [],// 退款商品列表查询（判断是否已退款）
      receiverDetailAddress: '', // 详细地址
      imgFlag: false,
      warehouseId: '', // 水库是否为空
      map: '',//地图
      initialization: 1,// 是否初始化地图
      timeNumbers: 0,
    }
  },
  watch: {
    'judgeGoodsCloseQuery.warehouseId'() {
      let noCode = [];
      let cakeArray = [];
      this.shopslist.forEach(item => {
        if(item.skuCode !== '' && item.skuCode !== null && item.skuCode !== undefined){
          console.log('sku')
        } else {
          noCode.push(false)
        }
      })
      if(noCode.indexOf(false) > -1) {
        if(this.warehouseId !== this.ruleForm.warehouseId) {
          this.$message({
            type: 'warning',
            message: 'sku码不能为空'
          })
        }
      } else {
        this.shopslist.forEach(item => {
          this.judgeGoodsCloseQuery.skuCode = item.skuCode;
          judgeGoodsClose(this.judgeGoodsCloseQuery).then(res => {
            if(res.data.code == 200) {
              if(res.data.data == true) {
                cakeArray.push(false)
              }
            }
          })
        })
        if(cakeArray.indexOf(false) > -1) {
          this.$message({
            type: 'warning',
            message: '所选仓库没有生产该蛋糕的原料,请联系用户更换蛋糕'
          })
          this.ruleForm.branchWarehouse = '';
        }
      }
    },
    'deliveryTimeUpdateFlag'() {
      // console.log('this.$refs.getdeliveryTime',this.$refs.getdeliveryTime,this.warehouseLoadList)
      if(this.$refs.getdeliveryTime !== undefined && this.$refs.getdeliveryTime !== '') {
        if(this.$refs.getdeliveryTime.getdeliveryStartTime !== '' && this.$refs.getdeliveryTime.deliveryStartTime !== '') {
          // console.log('')
          this.selectdelitimeFlag = true;
          this.getdeliverytimeFlag = true;
        }
      }
    },
    'deptName'() {
      if(this.initialization > 1) this.map.clearMap();
      this.initialization = 1;
    },
    'reminderFlag'() {
      if(this.reminderFlag) {
        if(new Date(this.ruleForm.deliveryStartTime).getTime() > new Date().getTime()) {
          this.reminderForm.reminderType = 1;
        } else if (new Date(this.ruleForm.deliveryEndTime).getTime() < new Date().getTime()) {
          this.reminderForm.reminderType = 3;
        } else {
          this.reminderForm.reminderType = 2;
        }
      }
    }
  },
  created() {
    this.getList()
  },
  mounted() {
    // this.getList()
    this.cityId = JSON.parse(window.localStorage.getItem("saber-areaId")).content
    // 城市
    citySelect(this.cityLi).then(res => {
      this.cityselect = res.data.data;
    })
    // 渠道类别列表
    this.getOrderChannelTypeList()
    // 退订原因列表
    getUnsubscribeReasonList().then(res => {
      this.returnOrderReasonList = res.data.data;
    });
    // 是否生产
    getIsProductionList().then(res => {
      this.whetherProduceList = res.data.data;
    });
    // 蛋糕去向
    getCakeWhereaboutsList().then(res => {
      this.cakeWhereaboutsList = res.data.data;
    });
    // 商品类型选择
    this.getCategories()
    let _this = this;
    // 点击页面空白处
    document.onclick = function(event) {
      var event = event || window.event;
      let targetId = event.target.id;
      let parentId = event.target.parentElement.parentElement.id;
      if(event.target.parentElement.parentElement.parentElement !== null) {
        let parentParentId = event.target.parentElement.parentElement.parentElement.id;
        // 不等于当前点点击的名字
        if((targetId !== 'getDetail') && (targetId !== 'mapDiv') && (parentId !== 'mapDiv') && (parentParentId !== 'mapDiv')) {
          _this.addressFlagcopy = _this.isaddressFlagcopy = false;
        }
      }
    }
    // 进入此页面开始计时
    this.overTimeOrder();
  },
  methods: {
    // 渠道类型空格过滤
    channelFilter(e) {
      if(e.keyCode == 32) {
        e.returnValue = false;
      }
    },
    getChannel(data) {
      // console.log('data',data)
      if(data) {
        this.ruleForm.channel = data.value
        this.ruleForm.channelName = data.label
      }
    },
    // 渠道类别列表
    getOrderChannelTypeList() {
      getOrderChannelTypeList().then(res => {
        this.channelTypellist = res.data.data;
      })
    },
    // 渠道类别列表
    getOrderChannelTypeListCopy(callback) {
      getOrderChannelTypeList().then(res => {
        this.channelTypellist = res.data.data;
        callback(this.channelTypellist,this.ruleForm.channelType);
      })
    },
    getList() {
      this.preservationFlag = false;// 保存信息标记
      let _this = this;
      this.detailLoading = true;
      this.querydetail.orderId = getUrlKey('id');
      this.formInline.id = getUrlKey('id');
      let goodsTypeNameKind = [];
      detailList(this.querydetail).then(res => {
        this.closelist = res.data.data;
        this.shopcloselist = JSON.stringify(res.data.data); // 蛋糕编辑弹框关闭，对应添加的蛋糕不保存
        this.shopcloselist = JSON.parse(this.shopcloselist); // 蛋糕编辑弹框关闭，对应添加的蛋糕不保存
        this.shopslist = res.data.data
        this.shoplist = res.data.data
        this.shoplist.forEach(item => {
          if(item.goodsTypeName !== '蛋糕' && item.goodsTypeName !== '配件' && item.goodsTypeName !== '服务费' && item.goodsTypeName !== '定制蛋糕') {
            item.categoryIdArray = [];
            item.cake = 2
          } else {
            item.cake = 1
          }
          goodsTypeNameKind.push(item.goodsTypeName)
          if(item.goodsSpecs == '') {
            item.goodsSpecsFlags = true;
          } else {
            item.goodsSpecsFlags = false;
          }
        })
        console.log('this.shoplist',this.shoplist)
        setTimeout(() => {
          this.detailLoading = false;
        }, 0.5 * 1000);
      })
      orderList(this.formInline).then(res => {
        // this.getOrderChannelTypeList();
        // 渠道类别列表
        res.data.data.rows[0].sumPrice = (res.data.data.rows[0].totalPrice/100).toFixed(2);
        this.refundForm.refundMoney = (res.data.data.rows[0].totalPrice/100).toFixed(2); // 退款金额默认值
        this.refundForm.store = res.data.data.rows[0].merchantName;// 退款门店默认值
        let result = res.data.data.rows[0];
        this.ruleForm = res.data.data.rows[0];
        // 渠道类别列表
        this.getOrderChannelTypeListCopy(function(channelTypellist,channelType){
          // 渠道类别列表
          channelTypellist.forEach(item => {
            if(item.channelKey == channelType) {
              // console.log('item',item.channelKey)
              // 获取渠道
              _this.getChannelList.parentId = item.id;
              // 渠道列表接口
              getOrderChannelList(_this.getChannelList).then(res => {
                // console.log('res.data.data',res.data.data)
                _this.channerllist = res.data.data;
              })
            }
          })
        })
        this.warehouseId = JSON.stringify(res.data.data.rows[0].warehouseId);
        this.warehouseId = JSON.parse(this.warehouseId);
        this.orderStatus = JSON.stringify(res.data.data.rows[0].status);
        this.orderStatus = JSON.parse(this.orderStatus);
        this.receiverDetailAddress = JSON.stringify(res.data.data.rows[0].receiverAddress);
        this.receiverDetailAddress = JSON.parse(this.receiverDetailAddress);
        this.deptId = res.data.data.rows[0].deptId;
        this.getdelOrderStartTime = res.data.data.rows[0].deliveryStartTime.slice(0,11);
        if(this.getdelOrderStartTime !== '') this.getdeliveryStartTime = this.getdelOrderStartTime;
        this.deliveryStart = res.data.data.rows[0].deliveryStartTime.slice(5,16);
        this.PendingEndTime = res.data.data.rows[0].deliveryEndTime.slice(11,16);
        this.PendingStartTime = res.data.data.rows[0].deliveryStartTime.slice(5,16);
        this.ruleForm.StartTime = this.ruleForm.deliveryStartTime.slice(5,16);
        this.ruleForm.EndTime = this.ruleForm.deliveryEndTime.slice(11,16);
        this.getSurplusWarehouseLoadQuery.warehouseId = this.ruleForm.warehouseId //获取对应的仓库负荷的id
        // 未确认订单若有时间，则加在配送备注中
        if(this.ruleForm.status == 1 && res.data.data.rows[0].deliveryStartTime.slice(5,16) !== '') {
          this.deliveryTimeNotes = result.deliveryNotes.substring(0,result.deliveryNotes.lastIndexOf("##"));
          this.deliveryMarksStart = this.deliveryTimeNotes.slice(5,16);
          this.deliveryMarksEnd = this.deliveryTimeNotes.slice(21,27);
          this.deliveryTimeEndNotes = this.ruleForm.deliveryNotes.substring(this.ruleForm.deliveryNotes.lastIndexOf("##")+2);
          if(this.ruleForm.deliveryNotes == '') {
            this.deliveryTimeNotes = '';
            this.ruleForm.deliveryNotes = '';
          } else {
            if(this.ruleForm.deliveryNotes.indexOf('#') > -1) {
              this.ruleForm.deliveryNotes = this.deliveryTimeEndNotes
            }
          }
        } else if(this.ruleForm.status !== 1 && res.data.data.rows[0].deliveryStartTime.slice(5,16) !== '') {
          // this.deliveryTimeNotes = result.deliveryNotes.substring(0,result.deliveryNotes.lastIndexOf("##"));
          this.deliveryTimeEndNotes = result.deliveryNotes.substring(result.deliveryNotes.lastIndexOf("##")+2);
          if(this.ruleForm.deliveryNotes.indexOf('#') > -1) {
            this.ruleForm.deliveryNotes = this.deliveryTimeEndNotes
          }
        }
        // 获取总仓
        this.getMainWarehouse(this.ruleForm.deptId)
        // 未点击城市时划区域
        if(this.ruleForm.deptId == 1) {
          let deptIdCopy = 1
          this.ruleForm.deptIdCopy = deptIdCopy
          this.ruleForm.deptId = ''
          this.getNationwide()
        } else {
          this.getArea(this.ruleForm.deptId)
          this.getWarehouseName.latitude = this.ruleForm.latitude;
          this.getWarehouseName.longitude = this.ruleForm.longitude;
          getWarehouseName(this.getWarehouseName).then(res => {
            if(res.data.msg == '操作成功') {
              if((res.data.data.cityId !== this.ruleForm.deptId) && this.ruleForm.status == 1) {
                this.$confirm('您选择的地址不在配送范围内, 请联系用户！', '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(() => {
                  this.$message({
                    type: 'warning',
                    message: '请重新确认配送地址'
                  })
                }).catch(() => {
                  this.$message({
                    type: 'warning',
                    message: '请重新确认配送地址'
                  })
                })
              }
            } else if (res.data.msg == '暂无承载数据' && this.ruleForm.status == 1) {
              this.$confirm('您选择的地址不在配送范围内, 请联系用户！', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                this.$message({
                  type: 'warning',
                  message: '请重新确认配送地址'
                })
              }).catch(() => {
                this.$message({
                  type: 'warning',
                  message: '请重新确认配送地址'
                })
              })
            }
          })
        }
        // 工单按钮显隐
        this.judgingState(this.ruleForm.status,goodsTypeNameKind)
      })
    },
    // 获取分仓id
    getwarehouseId(val) {
      this.ruleForm.warehouseId = val
      this.getSurplusWarehouseLoadQuery.warehouseId = val
      this.judgeGoodsCloseQuery.warehouseId = val // 判断当前商品是否关闭请求仓库id
    },
    // 下单仓库城市获取
    cityclick(data) {
      if(data){
        this.deptName=data.label;
        this.ruleForm.deptId=data.value;
        this.ruleForm.deptName = data.label
      }
      this.latitudeFlag = false;
      this.startArea(data.value);
    },
    startArea(datacity) {
      this.getMainWarehouseList.parentId = datacity;
      this.getWarehousesByDeptIds.cityId = datacity;
      getWarehouseList(this.getWarehousesByDeptIds).then(res => {
        this.getAreaScope = res.data.data;
        var isPointInRingList = [];
        var overlayGroupsArray = [];
        var marker = [];
        this.markers = [];
        // this.markers = ''
        let result = res.data.data;
        result.forEach((item,resultindex) => {
          marker.push([item.longitude,item.latitude,`${item.name}`]);
          if(result[resultindex].geoJson.geometry !== '') {
            overlayGroupsArray.push(result[resultindex].geoJson.geometry.coordinates[0]);
          }
        })
        if(this.latitude !== '' && this.latitude !== ''&& this.addressCopyname !== '' && this.latitudeFlag) {
          marker.push([this.longitude,this.latitude,this.addressCopyname]);
        } else if(this.latitudeFlag === 'initialcity') {
          marker.push([this.longitude,this.latitude,this.addressCopyname]);
        } else if (this.ruleForm.latitude !== undefined && this.ruleForm.longitude !== undefined && this.ruleForm.receiverAddress !== undefined) {
          if(this.ruleForm.latitude !== '' && this.ruleForm.longitude !== '' && this.ruleForm.receiverAddress !== '') {
            // marker.push([this.ruleForm.longitude,this.ruleForm.latitude,this.ruleForm.receiverAddress]);
            marker.push([this.ruleForm.longitude,this.ruleForm.latitude,this.addressCopyname]);
          }
        }
        this.markers = marker;
        this.overlayGroups = overlayGroupsArray;
        this.getAreaScopeMethod(this.overlayGroups);
      });
      if(!this.latitudeFlag) {
        // 总仓
        getMainWarehouseList(this.getMainWarehouseList).then(res => {
          let abbrResult = res.data.data
          if(abbrResult.length > 0) {
            abbrResult.forEach(item => {
              if (item.name == this.ruleForm.mainWarehouse) {
                this.ruleForm.mainWarehouse = item.name;
                this.citylist = abbrResult;
              } else {
                this.citylist = abbrResult;
                this.ruleForm.mainWarehouse = ''
                this.ruleForm.branchWarehouse = ''
              }
            })
          }
        })
      }
    },
    // 确认订单
    submitForm(formName) {
      // this.ruleForm.receiverDetailAddress = this.receiverDetailAddress;
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.preservationFlag = false;
          this.UnsubscribeFlag =false;
          this.refundFlag =false;
          this.updateMessage();
        } else {
          this.$confirm('还有信息未填完整，请补充完整?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.$message({
              type: 'warning',
              message: '请完善信息!'
            });
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消操作'
            });
          });
          return false;
        }
      });
    },
    // 保存信息
    preservation(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.preservationFlag = true;
          // console.log('preservationFlag',this.preservationFlag)
          this.UnsubscribeFlag =false;
          this.refundFlag =false;
          this.updateMessage();
        } else {
          this.$confirm('还有信息未填完整，请补充完整?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.$message({
              type: 'warning',
              message: '请完善信息!'
            });
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消操作'
            });
          });
          return false;
        }
      });
    },
    // 修改信息，确认订单
    updateMessage() {
      if(this.ruleForm.status == 1 && this.preservationFlag == false) {
        if(this.ruleForm.deliveryStartTime !== '' && this.ruleForm.deliveryEndTime !== '') {
          if(this.$refs.getdeliveryTime !== undefined) {
            if(this.$refs.getdeliveryTime.getdeliveryStartTime !== '' && this.$refs.getdeliveryTime.deliveryStartTime !== '') {
              this.ruleForm.deliveryStartTime = this.$refs.getdeliveryTime.deliveryTime + this.$refs.getdeliveryTime.deliveryStartTime
              this.ruleForm.deliveryEndTime = this.$refs.getdeliveryTime.deliveryTime + this.$refs.getdeliveryTime.deliveryEndTime
              // console.log('this.ruleForm.deliveryStartTime',this.ruleForm.deliveryStartTime,this.ruleForm.deliveryEndTime)
            }
          }
          this.getDelivery(this.ruleForm.deliveryStartTime);
          if(this.getDeliveryFlag) {
            this.statusUpdate();
          } else {
            this.$message.warning("该时间已过期，请重新选择");
          }
        } else {
          this.selectdelitimeFlag = false;
          if(this.$refs.getdeliveryTime !== undefined) {
            if(this.$refs.getdeliveryTime.getdeliveryStartTime !== '' && this.$refs.getdeliveryTime.deliveryStartTime !== '') {
              // console.log
              this.ruleForm.deliveryStartTime = this.$refs.getdeliveryTime.deliveryTime + this.$refs.getdeliveryTime.deliveryStartTime
              this.ruleForm.deliveryEndTime = this.$refs.getdeliveryTime.deliveryTime + this.$refs.getdeliveryTime.deliveryEndTime
              // this.ruleForm.deliveryNotes = this.ruleForm.deliveryStartTime.slice(5,16) + '~' + this.ruleForm.deliveryEndTime.slice(11,16) + this.ruleForm.deliveryNotes
              // this.ruleForm.warehouseLoadId = this.$refs.getdeliveryTime.warehouseLoadId
              this.getDelivery(this.ruleForm.deliveryStartTime);
              if(this.getDeliveryFlag) {
                this.statusUpdate();
              } else {
                this.$message.warning("该时间已过期，请重新选择");
              }
            } else {
              this.$alert(`您还未选配送时间，请选择配送时间`, '提示', {
                confirmButtonText: '确定',
                callback: action => {
                  this.$message({
                    type: 'warning',
                    message: `请继续选择配送时间`
                  });
                }
              })
            }
          } else {
            this.$alert(`您还未选配送时间，请选择配送时间`, '提示', {
              confirmButtonText: '确定',
              callback: action => {
                this.$message({
                  type: 'warning',
                  message: `请继续选择配送时间`
                });
              }
            })
          }
        }
      } else {
        console.log('不需选时间');
        if(this.$refs.getdeliveryTime !== undefined && this.$refs.getdeliveryTime !== '') {
          if(this.$refs.getdeliveryTime.getdeliveryStartTime !== '' && this.$refs.getdeliveryTime.deliveryStartTime !== '') {
            this.ruleForm.deliveryStartTime = this.$refs.getdeliveryTime.deliveryTime + this.$refs.getdeliveryTime.deliveryStartTime
            this.ruleForm.deliveryEndTime = this.$refs.getdeliveryTime.deliveryTime + this.$refs.getdeliveryTime.deliveryEndTime
          }
        }
        this.getDelivery(this.ruleForm.deliveryStartTime);
        if(this.getDeliveryFlag) {
          this.statusUpdate();
        } else {
          this.$confirm('该配送时间已过期，是否继续修改订单?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.statusUpdate();
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消修改订单'
            });          
          });
        }
      }
    },
    // 修改信息，(退订退款)
    updateKindMessage() {
      this.statusUpdate();
    },
    // 未确认必须重新选择时间，其他状态判断是否有时间
    statusUpdate() {
      this.shopslist = this.shoplist;
      let skuCodeArrayFlag = []; // 判断skucode是否没有
      let skuCodeFlag = true; // 判断skucode是否没有
      let cakeArrayFlag = []; // 判断蛋糕中师傅含有已关闭的蛋糕数组
      let cakeFlag = true; // 判断蛋糕中师傅含有已关闭的蛋糕
      let goodsTypeNameFlag = true; // 商品类型标记
      let goodsTypeNameArray = []; // 判断商品类型的数组
      let cakeArray = [];
      let goodsSpecsArray = []; // 判断商品是否有规格
      let goodsNameArray = [];
      let goodsSpecsFlag = ''; // 判断商品是否有规格
      let goodsTypeNameFlags = [];
      let blessingsArray = []; // 判断祝福语是否超过字数限制
      let blessingsFlag = true; // 判断祝福语是否超过字数限制
      this.shopslist.forEach((item,index) => {
        if(item.skuCode == ''){
          skuCodeArrayFlag.push(false);
        }
        if(item.goodsSpecs == '') {
          if(this.UnsubscribeFlag || this.refundFlag) {
            item.goodsSpecs = '1'
          } else if (this.UnsubscribeFlag == false && this.refundFlag == false){
            goodsSpecsArray.push(false);
            goodsNameArray.push(item.goodsName);
          }
        }
        cakeArrayFlag.push(item.productionState);
        goodsTypeNameArray.push(item.goodsTypeName);
        this.judgeGoodsCloseQuery.warehouseId = this.ruleForm.warehouseId;
        this.judgeGoodsCloseQuery.skuCode = this.shopslist[index].skuCode;
        if(item.goodsTypeName !== '配件' && item.goodsTypeName !== '蛋糕' && item.goodsTypeName !== '服务费' &&item.goodsTypeName !== '定制蛋糕') {
          goodsTypeNameFlags.push(false);
        } else {
        }
        // 祝福语字数判断
        if(item.blessings !== '' && item.blessings !== undefined) {
          if(item.blessings.length > 16 && item.blessings.length !== undefined) blessingsArray.push(false);
        }
      })
      if(goodsTypeNameFlags.indexOf(false) > -1) {
        goodsTypeNameFlag = false;
        this.$message({
          showClose: true,
          message: '确认订单发起失败，请确认清楚商品类别',
          type: 'warning'
        });
      } else {
        goodsTypeNameFlag = true;
      }
      if(skuCodeArrayFlag.indexOf(false) > -1) {
        if(this.warehouseId !== this.ruleForm.warehouseId) {
          if(this.preservationFlag) {
            skuCodeFlag = true;
          } else {
            this.$message({
              type: 'warning',
              message: 'sku码不能为空'
            })
            skuCodeFlag = false;
          }
        } else if (this.orderStatus == 1 && this.preservationFlag == false && !this.UnsubscribeFlag && !this.refundFlag) {
          this.$message({
            type: 'warning',
            message: 'sku码不能为空'
          })
          skuCodeFlag = false;
        } else if (this.orderStatus == 1 && this.preservationFlag == true) {
          skuCodeFlag = true;
        } else if (this.UnsubscribeFlag || this.refundFlag) {
          skuCodeFlag = true;
        }
      } else {
        skuCodeFlag = true;
      }
      if(goodsSpecsArray.indexOf(false) > -1) {
        this.$message({
          type: 'warning',
          message: `蛋糕（${goodsNameArray}）没有规格，请联系用户更换蛋糕`
        })
        goodsSpecsFlag = false;
      } else {
        goodsSpecsFlag = true;
      }
      if(cakeArrayFlag.indexOf(6) > -1) {
        this.$message({
          showClose: true,
          message: '蛋糕中含有无货蛋糕，请联系用户更换蛋糕',
          type: 'warning'
        });
        cakeFlag = false;
      } else {
        cakeFlag = true;
      }
      let deliveryFlag = '';
      if(this.ruleForm.replaceDeliveryTime == 1 && this.UnsubscribeFlag == false && this.refundFlag == false && this.preservationFlag == false) {
        if(this.$refs.getdeliveryTime !== undefined && this.$refs.getdeliveryTime !== '' && this.$refs.getdeliveryTime.getdeliveryStartTime !== '' && this.$refs.getdeliveryTime.deliveryStartTime !== '') {
          deliveryFlag = true;
        } else {
          this.$message({
            showClose: true,
            message: '请确认配送时间',
            type: 'warning'
          });
          deliveryFlag = false;
        }
      } else {
        deliveryFlag = true;
      }
      if(blessingsArray.indexOf(false) > -1 && !this.UnsubscribeFlag && !this.refundFlag) {
        this.$message.warning('祝福语超过16个字');
        blessingsFlag = false;
      }
      if (skuCodeFlag && cakeFlag && deliveryFlag && goodsTypeNameFlag && goodsSpecsFlag && blessingsFlag) {
        this.ruleForm.orderDetailRequests = this.shopslist;
        this.ruleForm.totalPrice = this.ruleForm.sumPrice * 100;
        this.ruleForm.originalPrice = this.ruleForm.sumPrice * 100;
        this.ruleForm.locationAddress = this.receiverDetailAddress;// 订单定位地址
        let workOrderProvisionsIdsArray = [];
        // 商品长度不能为空
        if(this.ruleForm.orderDetailRequests.length > 0) {
          this.updateByProvisionsList.orderId = this.ruleForm.orderDetailRequests[0].orderId;
          this.phoneFlag = false;
          if((this.ruleForm.deliveryStartTime !== '' && this.UnsubscribeFlag == false && this.refundFlag == false && this.preservationFlag == false) || (this.UnsubscribeFlag == false && this.refundFlag == false && this.preservationFlag)) {
            if(this.deptName !== '' && this.deptName !== null && this.deptName !== undefined){
              if (this.ruleForm.mainWarehouse !== null && this.ruleForm.branchWarehouse !== null && this.ruleForm.branchWarehouse !== '' && this.ruleForm.branchWarehouse !== '') {
                let statusCode = this.ruleForm.status;
                this.updateStatus(statusCode,goodsTypeNameArray);
                let goodsTypeNameKind = [];
                let statusArrays = [];
                // console.log(this.preservationFlag == false,'this.preservationFlag == false')
                if(this.preservationFlag == false) {
                  this.ruleForm.orderDetailRequests.forEach((item,index) => {
                    goodsTypeNameKind.push(item.goodsTypeName);
                    statusArrays.push(item.productionState);
                    let productionStateCode = this.ruleForm.orderDetailRequests[index].productionState;
                    console.log(productionStateCode);
                    switch(parseInt(productionStateCode)){
                      // 未确认
                      case 1:
                        if(goodsTypeNameKind.indexOf('配件') > -1 && goodsTypeNameKind.indexOf('蛋糕') == -1 && goodsTypeNameKind.indexOf('服务费') == -1 && goodsTypeNameKind.indexOf('定制蛋糕') == -1) {
                          if(this.UnsubscribeFlag || this.refundFlag) {
                            // console.log('配件');
                            this.ruleForm.orderDetailRequests[index].productionState = 1;
                            this.ruleForm.orderDetailRequests[index].productionStateName = "未确认";
                          } else {
                            this.ruleForm.orderDetailRequests[index].productionState = 4;
                            this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                          }
                        } else if (goodsTypeNameKind.indexOf('配件') == -1 && goodsTypeNameKind.indexOf('蛋糕') == -1 && goodsTypeNameKind.indexOf('服务费') > -1 && goodsTypeNameKind.indexOf('定制蛋糕') == -1) {
                          if(this.UnsubscribeFlag || this.refundFlag) {
                            this.ruleForm.orderDetailRequests[index].productionState = 1;
                            this.ruleForm.orderDetailRequests[index].productionStateName = "未确认";
                          } else {
                            this.ruleForm.orderDetailRequests[index].productionState = 8;
                            this.ruleForm.orderDetailRequests[index].productionStateName = "已签收";
                          }
                        } else {
                          if(this.UnsubscribeFlag || this.refundFlag) {
                            if(item.goodsTypeName == '服务费') {
                              this.ruleForm.orderDetailRequests[index].productionState = 8;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已签收";
                            } else if (item.goodsTypeName == '配件') {
                              this.ruleForm.orderDetailRequests[index].productionState = 4;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                            } else {
                              this.ruleForm.orderDetailRequests[index].productionState = 1;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "未确认";
                            }
                          } else {
                            if(item.goodsTypeName == '服务费') {
                              this.ruleForm.orderDetailRequests[index].productionState = 8;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已签收";
                            } else if (item.goodsTypeName == '配件') {
                              this.ruleForm.orderDetailRequests[index].productionState = 4;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                            } else if (item.goodsTypeName == '蛋糕' && item.workOrderProvisionsType == '备款') {
                              this.ruleForm.orderDetailRequests[index].productionState = 4;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                            } else if (item.goodsTypeName == '定制蛋糕' && item.workOrderProvisionsType == '备款') {
                              this.ruleForm.orderDetailRequests[index].productionState = 4;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                            } else {
                              if(this.ruleForm.orderDetailRequests[index].productionState == 1) {
                                this.ruleForm.orderDetailRequests[index].productionState = 2;
                                this.ruleForm.orderDetailRequests[index].productionStateName = "待生产";
                              }
                              if(statusArrays.indexOf(1) > -1) {
                                this.ruleForm.status = 4;
                                this.ruleForm.statusName = "待生产";
                              }
                            }
                          }
                        };
                        break;
                      // 已入库
                      case 4:
                        if(goodsTypeNameKind.indexOf('配件') > -1 && goodsTypeNameKind.indexOf('蛋糕') == -1 && goodsTypeNameKind.indexOf('服务费') == -1 && goodsTypeNameKind.indexOf('定制蛋糕') == -1) {
                          if(this.UnsubscribeFlag || this.refundFlag) {
                            // console.log('配件');
                            this.ruleForm.orderDetailRequests[index].productionState = 1;
                            this.ruleForm.orderDetailRequests[index].productionStateName = "未确认";
                          } else {
                            this.ruleForm.orderDetailRequests[index].productionState = 4;
                            this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                          }
                        } else if (goodsTypeNameKind.indexOf('配件') == -1 && goodsTypeNameKind.indexOf('蛋糕') == -1 && goodsTypeNameKind.indexOf('服务费') > -1 && goodsTypeNameKind.indexOf('定制蛋糕') == -1) {
                          if(this.UnsubscribeFlag || this.refundFlag) {
                            this.ruleForm.orderDetailRequests[index].productionState = 1;
                            this.ruleForm.orderDetailRequests[index].productionStateName = "未确认";
                          } else {
                            this.ruleForm.orderDetailRequests[index].productionState = 8;
                            this.ruleForm.orderDetailRequests[index].productionStateName = "已签收";
                          }
                        } else {
                          if(this.UnsubscribeFlag || this.refundFlag) {
                            if(item.goodsTypeName == '服务费') {
                              this.ruleForm.orderDetailRequests[index].productionState = 8;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已签收";
                            } else if (item.goodsTypeName == '配件') {
                              this.ruleForm.orderDetailRequests[index].productionState = 4;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                            } else {
                              this.ruleForm.orderDetailRequests[index].productionState = 1;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "未确认";
                            }
                          } else {
                            if(item.goodsTypeName == '服务费') {
                              this.ruleForm.orderDetailRequests[index].productionState = 8;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已签收";
                            } else if (item.goodsTypeName == '配件') {
                              this.ruleForm.orderDetailRequests[index].productionState = 4;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                            } else if (item.goodsTypeName == '蛋糕' && item.workOrderProvisionsType == '备款') {
                              this.ruleForm.orderDetailRequests[index].productionState = 4;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                            } else if (item.goodsTypeName == '定制蛋糕' && item.workOrderProvisionsType == '备款') {
                              this.ruleForm.orderDetailRequests[index].productionState = 4;
                              this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                            } else {
                              if(this.ruleForm.orderDetailRequests[index].productionState == 1) {
                                this.ruleForm.orderDetailRequests[index].productionState = 2;
                                this.ruleForm.orderDetailRequests[index].productionStateName = "待生产";
                              }
                              if(statusArrays.indexOf(1) > -1) {
                                this.ruleForm.status = 4;
                                this.ruleForm.statusName = "待生产";
                              }
                            }
                          }
                        };
                        break;
                      default:
                        break;
                    }
                  })
                }
                if(this.orderStatus == 1 && this.preservationFlag == false) {
                  let cakeStatusArrays = [];
                  this.ruleForm.orderDetailRequests.forEach(cakeitem => {
                    cakeStatusArrays.push(cakeitem.productionState)
                  })
                  if(cakeStatusArrays.indexOf(1) == -1 && cakeStatusArrays.indexOf(2) == -1 && cakeStatusArrays.indexOf(4) > -1) {
                    this.ruleForm.status = 6;
                    this.ruleForm.statusName = "已入库";
                  }
                  if(this.ruleForm.refundMark == '平台退款中') {
                    this.$confirm('平台退款中，是否要确认订单?', '提示', {
                      confirmButtonText: '确定',
                      cancelButtonText: '取消',
                      type: 'warning'
                    }).then(() => {
                      this.confirmOrder();
                    }).catch(() => {
                      this.$message({
                        type: 'info',
                        message: '已取操作'
                      });          
                    });
                  } else {
                    this.confirmOrder();
                  }
                } else if (this.preservationFlag) {
                  if(this.orderStatus == 1) {
                    this.ruleForm.orderDetailRequests.forEach(cakeitem => {
                      if(cakeitem.productionState == 2) {
                        cakeitem.productionState = 1;
                        cakeitem.productionStateName = "未确认";
                      }
                    })
                    this.ruleForm.status = 1;
                    this.ruleForm.statusName = "未确认";
                    if(this.ruleForm.refundMark == '平台退款中') {
                      this.$confirm('平台退款中，是否要修改订单信息?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(() => {
                        this.confirmUpdate();
                      }).catch(() => {
                        this.$message({
                          type: 'info',
                          message: '已取消操作'
                        });          
                      });
                    } else {
                      this.confirmUpdate();
                    }
                  } else {
                    // console.log('this.ruleForm请求参数',this.ruleForm)
                    if(this.ruleForm.refundMark == '平台退款中') {
                      this.$confirm('平台退款中，是否要修改订单信息?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(() => {
                        this.confirmUpdate();
                      }).catch(() => {
                        this.$message({
                          type: 'info',
                          message: '已取消操作'
                        });          
                      });
                    } else {
                      this.confirmUpdate();
                    }
                  }
                }
              } else {
                this.$message({
                  type: "warning",
                  message: "您还未选仓库，请选择仓库"
                });
              }
            } else {
              this.$message({
                type: "warning",
                message: "您还未选城市，请选择城市"
              });
            }
          } else if ((this.ruleForm.deliveryStartTime == '' || this.ruleForm.deliveryEndTime == '') && (this.UnsubscribeFlag == false && this.refundFlag == false)){
            this.$alert(`您还未选配送时间，请选择配送时间`, '提示', {
              confirmButtonText: '确定',
              callback: action => {
                this.$message({
                  type: 'warning',
                  message: `请继续选择配送时间`
                });
              }
            })
          }
          if(this.UnsubscribeFlag == true || this.refundFlag == true && this.ruleForm.status == 1) {
            // if(this.ruleForm.receiverDetailAddress !== undefined) {
            //   this.ruleForm.receiverAddress = this.ruleForm.receiverAddress + this.ruleForm.receiverDetailAddress;
            // } else {
            //   this.ruleForm.receiverAddress = this.ruleForm.receiverAddress;
            // }
            if(this.deptName !== '' && this.deptName !== null && this.deptName !== undefined){
              let statusCode = this.ruleForm.status;
              this.updateStatus(statusCode,goodsTypeNameArray);
              let goodsTypeNameKind = [];
              this.ruleForm.orderDetailRequests.forEach((item,index) => {
                goodsTypeNameKind.push(item.goodsTypeName);
                let productionStateCode = this.ruleForm.orderDetailRequests[index].productionState;
                // console.log(productionStateCode);
                switch(parseInt(productionStateCode)){
                  // 未确认
                  case 1:
                    if(goodsTypeNameKind.indexOf('配件') > -1 && goodsTypeNameKind.indexOf('蛋糕') == -1 && goodsTypeNameKind.indexOf('服务费') == -1 && goodsTypeNameKind.indexOf('定制蛋糕') == -1) {
                      if(this.UnsubscribeFlag || this.refundFlag) {
                        // console.log('配件');
                        this.ruleForm.orderDetailRequests[index].productionState = 1;
                        this.ruleForm.orderDetailRequests[index].productionStateName = "未确认";
                      } else {
                        this.ruleForm.orderDetailRequests[index].productionState = 4;
                        this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                      }
                    } else if (goodsTypeNameKind.indexOf('配件') == -1 && goodsTypeNameKind.indexOf('蛋糕') == -1 && goodsTypeNameKind.indexOf('服务费') > -1 && goodsTypeNameKind.indexOf('定制蛋糕') == -1) {
                      if(this.UnsubscribeFlag || this.refundFlag) {
                        this.ruleForm.orderDetailRequests[index].productionState = 1;
                        this.ruleForm.orderDetailRequests[index].productionStateName = "未确认";
                      } else {
                        this.ruleForm.orderDetailRequests[index].productionState = 8;
                        this.ruleForm.orderDetailRequests[index].productionStateName = "已签收";
                      }
                    } else {
                      if(this.UnsubscribeFlag || this.refundFlag) {
                        if(item.goodsTypeName == '服务费') {
                          this.ruleForm.orderDetailRequests[index].productionState = 8;
                          this.ruleForm.orderDetailRequests[index].productionStateName = "已签收";
                        } else if (item.goodsTypeName == '配件') {
                          this.ruleForm.orderDetailRequests[index].productionState = 4;
                          this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                        } else {
                          this.ruleForm.orderDetailRequests[index].productionState = 1;
                          this.ruleForm.orderDetailRequests[index].productionStateName = "未确认";
                        }
                      } else {
                        if(item.goodsTypeName == '服务费') {
                          this.ruleForm.orderDetailRequests[index].productionState = 8;
                          this.ruleForm.orderDetailRequests[index].productionStateName = "已签收";
                        } else if (item.goodsTypeName == '配件') {
                          this.ruleForm.orderDetailRequests[index].productionState = 4;
                          this.ruleForm.orderDetailRequests[index].productionStateName = "已入库";
                        } else {
                          this.ruleForm.orderDetailRequests[index].productionState = 2;
                          this.ruleForm.orderDetailRequests[index].productionStateName = "待生产";
                        }
                      }
                    };
                    break;
                  default:
                    break;
                }
              })
              // this.uniCode();
              refundUnsubscribeConfirmOrder(this.ruleForm).then(res => {
                if(res.data.code == 200) {
                  updateByProvisions(this.updateByProvisionsList).then(res => {
                    if(res.data.code == 200) {
                      if(this.UnsubscribeFlag) this.returnGoodsFlag = true;
                      if(this.refundFlag) this.refundOpenFlag = true;
                      this.formInline.deptId = this.ruleForm.deptId;
                      // console.log('this.ruleForm.deptId',this.ruleForm.deptId)
                      // this.getList();
                    }
                  })
                }
              }).catch(err => {
                this.getList();
                console.log(err)
                // alert(err)
              })
            } else {
              this.$message({
                type: "warning",
                message: "您还未选城市，请选择城市"
              });
            }
          }
        } else {
          this.$confirm('你还未添加蛋糕，请添加蛋糕?', '提示', {
            showCancelButton: false,
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.$message.warning("请继续添加蛋糕");
          })
        }
      }
      // console.log('111',skuCodeFlag,cakeFlag,deliveryFlag,goodsTypeNameFlag)
    },
    // 编码
    uniCode() {
      this.ruleForm.productionNotes = escape(this.ruleForm.productionNotes); // 生产备注
      this.ruleForm.deliveryNotes = escape(this.ruleForm.deliveryNotes); // 配送备注
      this.ruleForm.customerServiceNotes = escape(this.ruleForm.customerServiceNotes); // 客服备注
      this.ruleForm.customerNotes = escape(this.ruleForm.customerNotes); // 客户备注
      this.ruleForm.storeInfo = escape(this.ruleForm.storeInfo); // 门店信息
    },
    // 平台退款中（保存信息）
    confirmUpdate() {
      // this.uniCode();
      refundUnsubscribeConfirmOrder(this.ruleForm).then(res => {
        if(res.data.code == 200) {
          updateByProvisions(this.updateByProvisionsList).then(res => {
            if(res.data.code == 200) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              })
              this.UnsubscribeFlag == false;
              this.refundFlag == false;
              this.formInline.deptId = this.ruleForm.deptId;
              // this.getList();
              window.localStorage.setItem('routerFlag', false);
              setTimeout(() => {
                this.confirmTypeOrder();
                // window.opener.location.reload();
              }, 1.5 * 1000);
            }
          })
        } else if (res.data.code == 300) {
          this.$message({
            type: 'warning',
            message: `${res.data.msg}`
          })
          this.getList();
        } else if (res.data.code == 301) {
          this.$message({
            type: 'warning',
            message: `${res.data.msg}`
          })
          this.getList();
        }
      }).catch(err => {
        this.getList();
        console.log(err);
        this.preservationFlag = false;
        // alert(err)
      })
    },
    // 确认订单请求
    confirmOrder() {
      // this.uniCode();
      updateList(this.ruleForm).then(res => {
        if(res.data.code == 200) {
          updateByProvisions(this.updateByProvisionsList).then(res => {
            if(res.data.code == 200) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              })
              this.UnsubscribeFlag == false;
              this.refundFlag == false;
              this.formInline.deptId = this.ruleForm.deptId;
              // this.getList();
              window.localStorage.setItem('routerFlag', true);
              setTimeout(() => {
                this.confirmTypeOrder();
                // window.opener.location.reload();
              }, 1.5 * 1000);
            }
          })
        } else if (res.data.code == 300) {
          this.$message({
            type: 'warning',
            message: `${res.data.msg}`
          })
          this.getList();
        } else if (res.data.code == 301) {
          this.$message({
            type: 'warning',
            message: `${res.data.msg}`
          })
          this.getList();
        }
        this.preservationFlag = false;
      }).catch(err => {
        console.log(err)
        this.getList();
        this.preservationFlag = false;
      })
    },
    // 确认订单、保存信息二次确认
    confirmTypeOrder() {
      this.$confirm(this.preservationFlag == false ? `下单成功,单号${this.ruleForm.xmbzNo}` : `保存成功,单号${this.ruleForm.xmbzNo}`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        showCancelButton: false,// 取消按钮
        showClose: false,// 右上角关闭按钮
        closeOnClickModal: false,// 点击遮罩
        closeOnPressEscape: false,// 通过按下 ESC 键关闭
        customClass: 'timeNumbers',
      }).then(() => {
        window.close();
      })
      document.onkeydown = function(e) {//按下回车弹窗消失
        let key = window.event.keyCode;
        //事件中keycode=13为回车事件
        if (key == 13) {
          window.close();
        }
      };
    },
    // 修改后状态
    updateStatus(statusCode,goodsTypeNameArray) {
      switch(parseInt(statusCode)){
        // 未确认
        case 1:
          // console.log((goodsTypeNameArray.indexOf('配件') > -1 && goodsTypeNameArray.indexOf('蛋糕') == -1 && goodsTypeNameArray.indexOf('服务费') == -1 && goodsTypeNameArray.indexOf('定制蛋糕') == -1))
          if(goodsTypeNameArray.indexOf('配件') > -1 && goodsTypeNameArray.indexOf('蛋糕') == -1 && goodsTypeNameArray.indexOf('服务费') == -1 && goodsTypeNameArray.indexOf('定制蛋糕') == -1) {
            if(this.UnsubscribeFlag || this.refundFlag) {
              this.ruleForm.status = 1;
              this.ruleForm.statusName = "未确认";
            } else {
              this.ruleForm.status = 6;
              this.ruleForm.statusName = "已入库";
            }
          } else if (goodsTypeNameArray.indexOf('配件') == -1 && goodsTypeNameArray.indexOf('蛋糕') == -1 && goodsTypeNameArray.indexOf('服务费') > -1 && goodsTypeNameArray.indexOf('定制蛋糕') == -1) {
            if(this.UnsubscribeFlag || this.refundFlag) {
              this.ruleForm.status = 1;
              this.ruleForm.statusName = "未确认";
            } else {
              this.ruleForm.status = 8;
              this.ruleForm.statusName = "已签收";
            }
          } else if (goodsTypeNameArray.indexOf('配件') > -1 && goodsTypeNameArray.indexOf('蛋糕') == -1 && goodsTypeNameArray.indexOf('服务费') > -1 && goodsTypeNameArray.indexOf('定制蛋糕') == -1) {
            if(this.UnsubscribeFlag || this.refundFlag) {
              this.ruleForm.status = 1;
              this.ruleForm.statusName = "未确认";
            } else {
              this.ruleForm.status = 6;
              this.ruleForm.statusName = "已入库";
            }
            // console.log('配件服务费')
          } else {
            if(this.UnsubscribeFlag || this.refundFlag) {
              this.ruleForm.status = 1;
              this.ruleForm.statusName = "未确认";
            } else {
              this.ruleForm.status = 4;
              this.ruleForm.statusName = "待生产";
            }
          };
          break;
        default:
          break;
      }
    },
    // 取消确认订单
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    deliveryTimeOpen() { // 选择配送时间
      // console.log('this.ruleForm.deliveryStartTime.slice(0,)',this.ruleForm.deliveryStartTime.slice(0,11),'000')
      this.orderStartEndTime = this.ruleForm.deliveryStartTime.slice(0,11);
      if(this.ruleForm.deptId !== '' && this.ruleForm.deptName !== '' && this.ruleForm.branchWarehouse !== undefined && this.ruleForm.mainWarehouse !== undefined) {
        if(this.ruleForm.branchWarehouse !== '' && this.ruleForm.mainWarehouse !== '') {
          this.deliveryTimeUpdateFlag = true;
          this.getgetSurplusWarehouseLoadList();
        } else {
          this.$message({
            type: 'warning',
            message: '请选择仓库'
          })
        }
      } else {
        this.$message({
          type: 'warning',
          message: '请选择仓库'
        })
      }
      // console.log('333',this.ruleForm.deptId,this.ruleForm.deptName,'444',this.ruleForm.branchWarehouse,this.ruleForm.mainWarehouse)
    },
    cancelSelectTime() { // 取消选择配送时间
      this.deliveryTimeUpdateFlag = false;
      this.selectdelitimeFlag = false;
      this.$refs.getdeliveryTime.deliveryEndTime = '';
      this.$refs.getdeliveryTime.deliveryStartTime = '';
      this.$refs.getdeliveryTime.checkedIndex = '';
    },
    // 配送时间关闭弹窗
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(() => {
          this.deliveryTimeUpdateFlag = false;
          this.selectdelitimeFlag = false;
          this.$refs.getdeliveryTime.deliveryEndTime = '';
          this.$refs.getdeliveryTime.deliveryStartTime = '';
          this.$refs.getdeliveryTime.checkedIndex = '';
          done();
        })
        .catch(() => {});
    },
    selectSubmit() {
      if(this.$refs.getdeliveryTime.deliveryEndTime == '' || this.$refs.getdeliveryTime.ischecked.indexOf(true) == -1) {
        this.$message({
          message: '配送时间不能为空',
          type: 'warning'
        });
      } else {
        this.ruleForm.StartTime = (this.$refs.getdeliveryTime.getdeliveryStartTime+this.$refs.getdeliveryTime.deliveryStartTime).slice(5,16)
        this.ruleForm.EndTime = (this.$refs.getdeliveryTime.getdeliveryStartTime+this.$refs.getdeliveryTime.deliveryEndTime).slice(11,16)
        this.deliveryTimeUpdateFlag = false;
      }
    },
    // 判断订单配送时间是否小于当前时间
    getDelivery(timeval) {
      let tiemlist = [
        '08:00','08:30','09:00','09:30','10:00','10:30','11:00','11:30','12:00','12:30','13:00','13:30','14:00','14:30','15:00','15:30','16:00','16:30','17:00','17:30','18:00','18:30','19:00','19:30','20:00','20:30','21:00','21:30','22:00','22:30','23:00','23:30',
      ]
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1< 10? "0" + (new Date().getMonth() + 1): (new Date().getMonth() + 1);
      let dd = new Date().getDate() < 10? "0" + new Date().getDate(): new Date().getDate();
      let min = new Date().getMinutes() < 10? "0" + new Date().getMinutes(): new Date().getMinutes();
      let nowDate = yy + "-" + mm + "-" + dd + ' ';
      let nowHours = new Date().getHours() < 10? "0" + new Date().getHours() : new Date().getHours();
      // let deliveryTime = parseInt(this.timelist[index].slice(0,2))// 配送时间（小时）
      let orderYear = parseInt(timeval.slice(0,4))
      let orderMonth = parseInt(timeval.slice(5,7))
      let orderDate = parseInt(timeval.slice(8,10))
      let orderHour = parseInt(timeval.slice(11,13))
      // console.log(timeval,orderYear,yy,orderHour,mm)
      if(orderYear < yy) {
        this.getDeliveryFlag = false;
      } else if (orderYear > yy) {
        this.getDeliveryFlag = true;
      } else if (orderYear == yy) {
        if(orderMonth < mm) {
          this.getDeliveryFlag = false;
        } else if (orderMonth > mm) {
          this.getDeliveryFlag = true;
        } else if (orderMonth == mm) {
          if(orderDate < dd) {
            this.getDeliveryFlag = false;
          } else if (orderDate > dd) {
            this.getDeliveryFlag = true;
          } else if (orderDate == dd) {    
            if(orderHour < nowHours) {
              this.getDeliveryFlag = false;
            } else if (orderHour > nowHours) {
              this.getDeliveryFlag = true;
            } else if (orderHour == nowHours) {
              this.getDeliveryFlag = false;
            }
          }
        }
      }
      // if(this.$refs.getdeliveryTime.deliveryTime == nowDate) {
      //   if(Number(deliveryTime) > parseInt(nowHours) ) {
      //     tiemlist01.push(item)
      //   } else if (Number(deliveryTime) == parseInt(nowHours)) {
      //     console.log(item.slice(3,5),min)
      //     let minuu = item.slice(3,5)
      //     if(parseInt(min) < parseInt(minuu)) {
      //       tiemlist01.push(item)
      //     }
      //   } else {
      //   }
      // } else {
      //   tiemlist01 = [
      //     '08:00','08:30','09:00','09:30','10:00','10:30','11:00','11:30','12:00','12:30','13:00','13:30','14:00','14:30','15:00','15:30','16:00','16:30','17:00','17:30','18:00','18:30','19:00','19:30','20:00','20:30','21:00','21:30','22:00','22:30','23:00','23:30',
      //   ]
      // }
    },
    // 配送时间负荷
    getgetSurplusWarehouseLoadList() {
      this.detailLoading = true;
      // console.log('2578549966948352',this.getSurplusWarehouseLoadQuery)
      getSurplusWarehouseLoadList(this.getSurplusWarehouseLoadQuery).then(res => {
        this.timelist = res.data.data.warehouseLoadAddSonRequestList[0].timeSlotList;
        this.warehouseLoadList = res.data.data.warehouseLoadAddSonRequestList[0].warehouseLoadList;
        this.idList = res.data.data.warehouseLoadAddSonRequestList[0].idList;
        // console.log(`'this.timelist !== '' && this.warehouseLoadList !== '' && this.idList !== ''`,this.timelist !== '' && this.warehouseLoadList !== '' && this.idList !== '')
        if(this.timelist.length > 0 && this.warehouseLoadList.length > 0 && this.idList.length > 0) {
          this.detailLoading = false;
          // let listFlag = false;
          this.$refs.getdeliveryTime.disableChecked = false;
          this.checkedlist = [];
          let checklist = { };
          res.data.data.warehouseLoadAddSonRequestList[0].warehouseLoadList.forEach((item,index) => {
            checklist = { 'num' : res.data.data.warehouseLoadAddSonRequestList[0].warehouseLoadList[index] };
            this.checkedlist.push(checklist);
          })
          this.checkedlist.forEach(item => {
            this.$set(item, "checked", false)
          })
          if(this.$refs.getdeliveryTime.checkedIndex) {
            // console.log(this.$refs.getdeliveryTime.lastCheckedFlag,this.$refs.getdeliveryTime.lastdeliveryStartTime,this.$refs.getdeliveryTime.getdeliveryStartTime,(this.$refs.getdeliveryTime.lastdeliveryStartTime !== this.$refs.getdeliveryTime.getdeliveryStartTime))
            if(this.$refs.getdeliveryTime.lastCheckedFlag) {
              // console.log('000')
              this.checkedlist[this.$refs.getdeliveryTime.checkedIndex].checked = false;
              this.$refs.getdeliveryTime.disableChecked = false;
              // console.log('item',this.$refs.getdeliveryTime.ischecked,this.$refs.getdeliveryTime.checkedlist)
            } else {           
              // console.log(this.$refs.getdeliveryTime.lastdeliveryStartTime,this.$refs.getdeliveryTime.getdeliveryStartTime)
              this.checkedlist[this.$refs.getdeliveryTime.checkedIndex].checked = true;
              this.$refs.getdeliveryTime.disableChecked = true;
            }
          }
          this.timelist.forEach((item,index) => {
            let yy = new Date().getFullYear();
            let mm = new Date().getMonth() + 1< 10? "0" + (new Date().getMonth() + 1): (new Date().getMonth() + 1);
            let dd = new Date().getDate() < 10? "0" + new Date().getDate(): new Date().getDate();
            let nowDate = yy + "-" + mm + "-" + dd + ' ';
            let nowHours = new Date().getHours() < 10? "0" + new Date().getHours() : new Date().getHours();
            let deliveryTime = parseInt(this.timelist[index].slice(9,11));// 配送时间（小时）
            let orderYear = parseInt(this.$refs.getdeliveryTime.getdeliveryStartTime.slice(0,4))
            let orderHour = parseInt(this.$refs.getdeliveryTime.getdeliveryStartTime.slice(5,7))
            let orderDate = parseInt(this.$refs.getdeliveryTime.getdeliveryStartTime.slice(8,10))
            // console.log('orderDate',orderDate,'dd',dd,'yy',yy,'orderHour',orderHour,'mm',mm)
            if((orderYear <= yy) && (orderHour <= parseInt(mm)) && (orderDate < parseInt(dd))) {
              // console.log('小于当前月份、年份、日期')
              this.checkedlist[index].getHour = true;
            } else if((orderYear <= yy) && (orderHour < parseInt(mm)) && (orderDate >= parseInt(dd))) {
              // console.log('小于当前月份、年份，日期大于当前日期')
              this.checkedlist[index].getHour = true;
            } else if((orderYear <= yy) && (orderHour <= parseInt(mm)) && (orderDate == dd) && (Number(deliveryTime) <= ( parseInt(nowHours) + 1 ) ) ) {
              if(deliveryTime == 0) {
                this.checkedlist[index].getHour = false;
                this.timelist[index] = '23:00:00-24:00:00'
              } else {
                this.checkedlist[index].getHour = true;
              }
            } else {
              this.checkedlist[index].getHour = false;
              if(deliveryTime == 0) {
                this.timelist[index] = '23:00:00-24:00:00';
              }
            }
          })
        } else {
          this.$message.warning("该仓库设置存在问题，请更换仓库或联系快乐部主管补全仓库信息");
        }
        // console.log('this.checkedlist',this.checkedlist,res.data.data.warehouseLoadAddSonRequestList[0].warehouseLoadList)
      })
    },
    // 地图事件
    SearchAddress() {
      this.addressFlagcopy = true;
      let _this = this;
      var keywords = document.getElementById("getDetail").value;
      // console.log(keywords,'keywords')
      AMap.plugin('AMap.Autocomplete', function(){
        // 实例化Autocomplete
        var autoOptions = {
          city: '全国'
        }
        var autoComplete = new AMap.Autocomplete(autoOptions);
        autoComplete.search(keywords, function(status, result) {
          // 搜索成功时，result即是对应的匹配数据
          // console.log('result',result,result.tips)
          if(result.tips !== undefined) {
            // console.log('有数据')
            _this.addressList = [];
            result.tips.forEach(item => {
              if(item.district.indexOf(_this.ruleForm.deptName) > 1) _this.addressList.push(item);
            })
            result.tips.forEach(otheritem => {
              if(_this.addressList.indexOf(otheritem) == -1) _this.addressList.push(otheritem);
            })
          }
        })
      })
    },
    // 点击地图的列表获取经纬度
    getlnglat(index) {
      if(this.initialization > 1) this.map.clearMap();
      index = (this.currentPage - 1) * this.pagesize + index;
      let _this = this;
      if((typeof index) === 'string') index = 0;
      if(this.addressList[index].location !== undefined && this.addressList[index].location.lat !== undefined) {
        this.addressList[index].lat = this.addressList[index].location.lat;
        this.addressList[index].lng = this.addressList[index].location.lng;
      }
      let pois = this.addressList[index];
      if(pois.lat !== undefined) {
        // console.log('ooooooooooooo')
        this.getWarehouseName.latitude = pois.lat
        this.getWarehouseName.longitude = pois.lng
        this.latitude = pois.lat
        this.longitude = pois.lng
        this.addressCopyname = pois.name;
        if(this.overlayGroups !== '') {
          getWarehouseName(this.getWarehouseName).then(res => {
            if(res.data.msg == '操作成功') {
              this.getSeparateWarehouseList.deptId = res.data.data.deptId;
              this.ruleForm.mainWarehouseId = res.data.data.deptId;
              this.deptName = res.data.data.cityName
              this.ruleForm.deptId = res.data.data.cityId; ////////
              this.ruleForm.mainWarehouse = res.data.data.deptName; ///////
              this.ruleForm.warehouseId = res.data.data.id; /////////
              this.ruleForm.branchWarehouse = res.data.data.name; ////////
              this.getSurplusWarehouseLoadQuery.warehouseId = res.data.data.id; /////////
              this.judgeGoodsCloseQuery.warehouseId = res.data.data.id // 判断当前商品是否关闭请求仓库id
              if((typeof this.getSeparateWarehouseList.deptId) === 'number') {
                getSeparateWarehouseList(this.getSeparateWarehouseList).then(res => {
                  this.abbrlist = res.data.data;
                })
              }
              if(this.deptId == res.data.data.cityId) {
                // console.log('res.data.data没有更换城市',res.data.data)
                // this.ruleForm.receiverAddress = pois.name;
                this.receiverDetailAddress = pois.name;
                this.ruleForm.latitude = pois.lat;
                this.ruleForm.longitude = pois.lng;
                let lastmaker = [pois.lng, pois.lat,pois.name]
                this.markers[this.getAreaScope.length] = lastmaker
                this.latitudeFlag = 'initialcity';
                this.startArea(res.data.data.cityId);
              } else {
                // console.log('this.deptId',this.deptId)
                this.$confirm('已修改配送城市，是否继续？', '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(() => {
                  this.latitudeFlag = true;
                  this.ruleForm.deptName = res.data.data.cityName;
                  // this.ruleForm.receiverAddress = pois.name;
                  this.receiverDetailAddress = pois.name;
                  this.ruleForm.latitude = pois.lat;
                  this.ruleForm.longitude = pois.lng;
                  this.startArea(res.data.data.cityId);
                }).catch(() => {
                  this.$message({
                    type: 'info',
                    message: '已取消选择地址'
                  })
                })
              }
            } else if (res.data.msg == '暂无承载数据') {
              this.$confirm('您选择的地址不在配送范围内, 请联系用户！', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                // this.ruleForm.receiverAddress = pois.name;
                this.receiverDetailAddress = pois.name;
                this.ruleForm.latitude = pois.lat;
                this.ruleForm.longitude = pois.lng;
                if(this.formInline.deptId == 1 && this.ruleForm.deptId == '') {
                  // console.log('activeIndex',this.formInline.deptId,this.ruleForm.deptId == '')
                  this.startArea(this.formInline.deptId);
                } else {
                  // console.log('吴成在数据')
                  this.startArea(this.ruleForm.deptId);
                }
              }).catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消选择地址'
                })
              })
            }
            // console.log('res.data.data',res.data.data)
          })
        } else {
          this.$confirm('您还未选择城市, 请选则城市！', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.$message({
              type: 'warning',
              message: '请继续选择城市!'
            });
            this.ruleForm.address1 = ''
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消选择城市'
            });
          });
        }
      } else {
        this.$confirm('此地址不存在, 请重新选址！', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'warning',
            message: '请继续选择地址!'
          });
          // this.ruleForm.receiverAddress = ''
          this.receiverDetailAddress = '';
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消选择地址'
          });
        });
      }
    },
    //方向键（向上）
    selectTopItem () {
      if(this.addressList.length > 0 && this.addressList.length <= 5) {
        if (this.currentIndex >= 0 && this.currentIndex < this.addressList.length - 1) {
          this.currentIndex--;
        } else {
          this.currentIndex = 0;
        }
        // console.log('上',this.currentIndex)
      } else {
        if (this.currentIndex >= 0 && this.currentIndex < this.addressList.length - 1) {
          this.currentIndex--;
        } else {
          this.currentIndex = 0;
        }
      }
    },
    //方向键（向下）
    selectBottomItem (index) {
      if(this.addressList.length > 0 && this.addressList.length <= 5) {
        if (this.currentIndex >= 0 && this.currentIndex < this.addressList.length - 1) {
          this.currentIndex++;
        } else {
          this.currentIndex = 0;
        }
      } else {
        // console.log('2',this.currentIndex >= 0 && this.currentIndex < this.addressList.length - 1)
        if (this.currentIndex >= 0 && this.currentIndex < this.addressList.length - 1) {
          this.currentIndex++;
        } else {
          this.currentIndex = 0;
        }
      }
    },
    // 未分配城市订单（即全国订单）的标记
    getNationwide() {
      this.markersCopy = []
      if(this.map == '') {
        this.map = new AMap.Map("amapDemoCopy", {
          center: [116.400274, 39.905812],
          zoom: 14
        });
      }
      this.getWarehouseName.longitude = this.ruleForm.longitude
      this.getWarehouseName.latitude = this.ruleForm.latitude
      this.markersCopy[0] = [this.ruleForm.longitude, this.ruleForm.latitude,this.ruleForm.receiverAddress]
      this.markersCopy.forEach((item,index) => {
        var marker = new AMap.Marker({
          position: new AMap.LngLat(item[0], item[1]),
          icon:new AMap.Icon({
            image: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-red.png',
            size: new AMap.Size(28, 36),  //图标所处区域大小
            imageSize: new AMap.Size(28, 36) //图标大小
          }),
          offset: new AMap.Pixel(-13, -30),
          zoom: 10
        })
        // console.log(item)
        marker.setLabel({
          offset: new AMap.Pixel(10, 10), //设置文本标注偏移量
          content: `<div class='info'>${item[2]}</div>`, //设置文本标注内容
          direction: 'top' //设置文本标注方位
        });
        this.map.add([ marker ])
      })
      this.map.setZoomAndCenter(50, [this.ruleForm.longitude, this.ruleForm.latitude])
    },
    // 未点击城市时划区域
    getArea(deptId) {
      // console.log('this.ruleForm.deptId',deptId)
      this.getWarehousesByDeptIds.cityId = deptId;
      getWarehouseList(this.getWarehousesByDeptIds).then(res => {
        // console.log('划区域',res.data.data)
        this.getAreaScope = res.data.data;
        var isPointInRingList = [];
        var overlayGroupsArray = [];
        var marker = [];
        this.markers = [];
        // this.markers = ''
        let result = res.data.data;
        result.forEach((item,resultindex) => {
          // marker.push(item.longitude,item.latitude)
          // console.log(item.name)
          marker.push([item.longitude,item.latitude,`${item.name}`])
        // console.log(res[index].geoJson.geometry.coordinates,'res[index].geoJson.geometry.coordinates[0]')
          if(result[resultindex].geoJson.geometry !== '') {
            overlayGroupsArray.push(result[resultindex].geoJson.geometry.coordinates[0])
            result[resultindex].geoJson.geometry.coordinates[0].forEach((item) => {
              // console.log('item',item)
              isPointInRingList.push(item)
            })
          }
        })
        this.markers = marker;
        let lastmaker = [this.ruleForm.longitude, this.ruleForm.latitude,this.ruleForm.receiverAddress]
        this.markers[this.getAreaScope.length] = lastmaker
        // console.log('isPointInRingList','this.markers',this.markers)
        this.getAreaScopeArray = isPointInRingList;
        this.overlayGroups = overlayGroupsArray;
        this.getAreaScopeMethod(this.overlayGroups)
      })
    },
    // 划区域模块
    getAreaScopeMethod(subCoordinate){
      this.Unallocated(subCoordinate)
    },
    // 是否为未分配的订单
    Unallocated(subCoordinate) {
      if(this.map == '') {
        this.map = new AMap.Map("amapDemoCopy", {
          center: [116.400274, 39.905812],
          zoom: 14
        });
      }
      var path = subCoordinate
      var polygon = new AMap.Polygon({
        path: path,
        strokeColor: "#000",
        strokeWeight: 3,
        strokeOpacity: 1,
        fillOpacity: 0.4,
        fillColor: '#fff',
        zIndex: 50,
      })
      this.markers.forEach((item,index) => {
        // console.log(item[0],item[1])
        var marker = new AMap.Marker({
          position: new AMap.LngLat(item[0], item[1]),
          // size: new AMap.Size(15, 20),
          icon: new AMap.Icon({
            image: `${index == (this.markers.length - 1)? '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-red.png': '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png'}`,
            size: new AMap.Size(28, 36),  //图标所处区域大小
            imageSize: new AMap.Size(28, 36) //图标大小
          }),
          // icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png'
        })
        // console.log(item)
        marker.setLabel({
          offset: new AMap.Pixel(10, 10),  //设置文本标注偏移量
          content: `<div class='info'>${item[2]}</div>`, //设置文本标注内容
          direction: 'top' //设置文本标注方位
        });
        // map.add(marker)
        this.map.add([marker,polygon])
      })
      // 缩放地图到合适的视野级别
      if(this.initialization == 1) this.map.setFitView();
      this.initialization += 1;
      this.addressFlagcopy = this.isaddressFlagcopy = false;
      this.map.setZoomAndCenter(50, [this.markers[this.markers.length - 1][0],this.markers[this.markers.length - 1][1]]);
      // map.setFitView([ polygon ])
    },
    // 初始页currentPage、初始每页数据数pagesize和数据data
    handleSizeChange: function (size) {
      this.pagesize = size
    },
    handleCurrentChange: function(currentPage) {
      this.currentPage = currentPage
    },
    // 划过列表颜色改变
    changeColor(index) {
      this.currentIndex = index;
    },
    // 离开列表颜色改变
    loseColor(index) {
      this.currentIndex = index;
    },
    // 选择渠道类型
    getchannelTypeId(e) {
      // console.log('e.currentTarget.dataset',e.currentTarget.dataset)
      this.ruleForm.channelType = e.currentTarget.dataset.channeltype
      this.getChannelList.parentId = e.currentTarget.dataset.id
      // 渠道列表接口
      getOrderChannelList(this.getChannelList).then(res => {
        let result = res.data.data
        result.forEach(item => {
          if (item.channelKey == this.ruleForm.channel) {
            // console.log('有',item)
            this.channerllist = result;
          } else {
            this.channerllist = result;
            this.ruleForm.channel = '';
            this.ruleForm.channelName = ''
          }
        })
      })
    },
    // 下单仓库城市总仓获取
    getMainWarehouse(deptId) {
      // console.log('result',deptId)
      this.getMainWarehouseList.parentId = deptId;
      // 总仓
      if (this.getMainWarehouseList.parentId !== 1) {
        getMainWarehouseList(this.getMainWarehouseList).then(res => {
          let result = res.data.data;
          // console.log('result',result)
          this.citylist = result;
          // console.log('this.citylist',this.citylist)
          // result.forEach(item => {
          //   if(this.ruleForm.mainWarehouse == item.deptName) {
          //     this.citylist = result;
          //     console.log('总仓',item.parentId)
          //     // 对应总仓的分仓
          //   }
          // })
        })
      }
    },
    // 下单分仓获取
    wareclick(e) {
      // console.log('wareclick',e.currentTarget.dataset)
      this.getSeparateWarehouseList.deptId = e.currentTarget.dataset.id
      this.ruleForm.mainWarehouseId = Number(e.currentTarget.dataset.id);
      // this.getWarehousesByDeptIds.deptId = this.listMessage.wareHouse
      getSeparateWarehouseList(this.getSeparateWarehouseList).then(res => {
        let abbrResult = res.data.data;
        // console.log('abbrResult',abbrResult.length)
        if(abbrResult.length > 0) {
          abbrResult.forEach(item => {
            if (item.name == this.ruleForm.branchWarehouse) {
              this.ruleForm.branchWarehouse = item.name;
              this.abbrlist = abbrResult;
            } else if(item.name !== this.ruleForm.branchWarehouse) {
              this.abbrlist = abbrResult;
              this.ruleForm.branchWarehouse = ''
            }
          })
        } else {
          this.abbrlist = abbrResult;
          // console.log('this.abbrlist03',abbrResult)
          this.ruleForm.branchWarehouse = ''
        }
      })
      // console.log('this.ruleForm',this.ruleForm)
    },
    getwareHouseOpen(val) { // 获取区(即总仓)ruleForm
      // console.log(val,'val')
      // this.ruleForm.mainWarehouse = val
      this.ruleForm.mainWarehouse = val
    },
    // 判断订单状态
    judgingState(statusCode,goodsTypeNameKind) {
      switch(statusCode){
        // 未确认
        case 1:
          if (goodsTypeNameKind.indexOf('配件') == -1 && goodsTypeNameKind.indexOf('蛋糕') == -1 && goodsTypeNameKind.indexOf('服务费') > -1 && goodsTypeNameKind.indexOf('定制蛋糕') == -1) {
            this.returnOrderFlag = false;
            this.refundMoneyFlag = false;// 退款按钮
          } else {
            this.returnOrderFlag = true;// 退订按钮
            this.refundMoneyFlag = true;// 退款按钮
          }
          this.reminderOrderFlag = false;// 催单按钮
          this.frmLossOrderFlag = false;// 备款按钮
          this.complainOrderFlag = true;// 投诉按钮
          this.orderFlag = false;// 恢复订单
          this.journalFlag = true;// 确认订单
          // console.log(!this.$refs.pendDetail.updateOrderFlag);
          // if(!this.$refs.pendDetail.updateOrderFlag) {
          //   // console.log(!this.$refs.pendDetail.updateOrderFlag)
          //   this.$refs.pendDetail.cakeFlag = true //蛋糕修改按钮
          // };
          break;
        // // 确认中
        // case 2:
        //   this.returnOrderFlag = true;// 退订按钮
        //   this.refundMoneyFlag = false;// 退款按钮
        //   this.reminderOrderFlag = false;// 催单按钮
        //   this.frmLossOrderFlag = false;// 备款按钮
        //   this.complainOrderFlag = false;// 投诉按钮
        //   this.orderFlag = false;// 恢复订单
        //   break;
        // // 已确认
        // case 3:
        //   this.returnOrderFlag = true;// 退订按钮
        //   this.refundMoneyFlag = true;// 退款按钮
        //   this.reminderOrderFlag = true;// 催单按钮
        //   this.frmLossOrderFlag = false;// 备款按钮
        //   this.complainOrderFlag = true;// 投诉按钮
        //   this.orderFlag = false;// 恢复订单
        //   break;
        // 待生产
        case 4:
          if (goodsTypeNameKind.indexOf('配件') == -1 && goodsTypeNameKind.indexOf('蛋糕') == -1 && goodsTypeNameKind.indexOf('服务费') > -1 && goodsTypeNameKind.indexOf('定制蛋糕') == -1) {
            this.returnOrderFlag = false;
            this.refundMoneyFlag = false;// 退款按钮
            this.RefundNoReFlag = false;// 退款不退货
          } else {
            this.returnOrderFlag = true;// 退订按钮
            this.refundMoneyFlag = true;// 退款按钮
            this.RefundNoReFlag = true;// 退款不退货
          }
          this.reminderOrderFlag = true;// 催单按钮
          this.frmLossOrderFlag = false;// 备款按钮
          this.complainOrderFlag = true;// 投诉按钮
          this.orderFlag = false;// 恢复订单
          this.journalFlag = true;// 确认订单
          // this.$refs.pendDetail.cakeFlag = false; //蛋糕修改按钮
          break;
        // 生产中
        case 5:
          if (goodsTypeNameKind.indexOf('配件') == -1 && goodsTypeNameKind.indexOf('蛋糕') == -1 && goodsTypeNameKind.indexOf('服务费') > -1 && goodsTypeNameKind.indexOf('定制蛋糕') == -1) {
            this.returnOrderFlag = false;
            this.refundMoneyFlag = false;// 退款按钮
            this.RefundNoReFlag = false;// 退款不退货
          } else {
            this.returnOrderFlag = true;// 退订按钮
            this.refundMoneyFlag = true;// 退款按钮
            this.RefundNoReFlag = true;// 退款不退货
          }
          this.reminderOrderFlag = true;// 催单按钮
          this.frmLossOrderFlag = false;// 备款按钮
          this.complainOrderFlag = true;// 投诉按钮
          this.orderFlag = false;// 恢复订单
          this.journalFlag = true;// 确认订单
          // this.$refs.pendDetail.cakeFlag = false; //蛋糕修改按钮
          break;
        // 已入库
        case 6:
          this.refundMoneyFlag = true;// 退款按钮
          this.returnOrderFlag = false;// 退订按钮
          this.reminderOrderFlag = true;// 催单按钮
          this.RefundNoReFlag = true;// 退款不退货
          if ((goodsTypeNameKind.indexOf('配件') > -1 || goodsTypeNameKind.indexOf('服务费') > -1 || goodsTypeNameKind.indexOf('定制蛋糕') > -1) && (goodsTypeNameKind.indexOf('蛋糕') == -1)) {
            this.frmLossOrderFlag = false;
          } else {
            this.frmLossOrderFlag = true;// 备款按钮
          }
          this.complainOrderFlag = true;// 投诉按钮
          this.orderFlag = false;// 恢复订单
          this.journalFlag = true;// 确认订单
          // this.$refs.pendDetail.cakeFlag = false; //蛋糕修改按钮
          break;
        // 配送中
        case 7:
          if (goodsTypeNameKind.indexOf('配件') == -1 && goodsTypeNameKind.indexOf('蛋糕') == -1 && goodsTypeNameKind.indexOf('服务费') > -1 && goodsTypeNameKind.indexOf('定制蛋糕') == -1) {
            this.returnOrderFlag = false;
            this.refundMoneyFlag = false;// 退款按钮
            this.RefundNoReFlag = false;// 退款不退货
          } else {
            this.returnOrderFlag = true;// 退订按钮
            this.refundMoneyFlag = true;// 退款按钮
            this.RefundNoReFlag = true;// 退款不退货
          }
          this.reminderOrderFlag = true;// 催单按钮
          this.frmLossOrderFlag = false;// 备款按钮
          this.complainOrderFlag = true;// 投诉按钮
          this.orderFlag = false;// 恢复订单
          this.journalFlag = true;// 确认订单
          // this.$refs.pendDetail.cakeFlag = false; //蛋糕修改按钮
          break;
        // 已签收
        case 8:
          if (goodsTypeNameKind.indexOf('配件') == -1 && goodsTypeNameKind.indexOf('蛋糕') == -1 && goodsTypeNameKind.indexOf('服务费') > -1 && goodsTypeNameKind.indexOf('定制蛋糕') == -1) {
            this.returnOrderFlag = false;
            this.RefundNoReFlag = false;// 退款不退货
            this.refundMoneyFlag = false;// 退款按钮
          } else {
            this.returnOrderFlag = true;// 退订按钮
            this.RefundNoReFlag = true;// 退款不退货
            this.refundMoneyFlag = true;// 退款按钮
          }
          this.reminderOrderFlag = false;// 催单按钮
          this.frmLossOrderFlag = false;// 备款按钮
          this.complainOrderFlag = true;// 投诉按钮
          this.orderFlag = false;// 恢复订单
          this.journalFlag = true;// 确认订单
          // this.$refs.pendDetail.cakeFlag = false; //蛋糕修改按钮
          break;
        // 已退订
        case 9:
          this.returnOrderFlag = false;// 退订按钮
          this.refundMoneyFlag = true;// 退款按钮
          this.reminderOrderFlag = false;// 催单按钮
          this.frmLossOrderFlag = false;// 备款按钮
          this.complainOrderFlag = true;// 投诉按钮
          this.orderFlag = false;// 恢复订单
          this.journalFlag = true;// 确认订单
          // this.$refs.pendDetail.cakeFlag = false; //蛋糕修改按钮
          break;
        // // 已结账
        // case 10:
        //   this.returnOrderFlag = false;// 退订按钮
        //   this.refundMoneyFlag = true;// 退款按钮
        //   this.reminderOrderFlag = false;// 催单按钮
        //   this.frmLossOrderFlag = false;// 备款按钮
        //   this.complainOrderFlag = true;// 投诉按钮
        //   this.orderFlag = false;// 恢复订单
        //   break;
        // 退订待处理
        case 11:
          this.returnOrderFlag = false;// 退订按钮
          this.refundMoneyFlag = true;// 退款按钮
          this.reminderOrderFlag = false;// 催单按钮
          this.frmLossOrderFlag = false;// 备款按钮
          this.complainOrderFlag = true;// 投诉按钮
          this.orderFlag = false;// 恢复订单
          this.journalFlag = true;// 确认订单
          // this.$refs.pendDetail.cakeFlag = false; //蛋糕修改按钮
          break;
        // 中转中
        case 12:
          this.returnOrderFlag = false;// 退订按钮
          this.refundMoneyFlag = true;// 退款按钮
          this.reminderOrderFlag = true;// 催单按钮
          this.frmLossOrderFlag = false;// 备款按钮
          this.complainOrderFlag = true;// 投诉按钮
          this.orderFlag = false;// 恢复订单
          this.journalFlag = true;// 确认订单
          // this.$refs.pendDetail.cakeFlag = false; //蛋糕修改按钮
          break;
        // 到达分仓
        case 13:
          this.returnOrderFlag = false;// 退订按钮
          this.refundMoneyFlag = false;// 退款按钮
          this.reminderOrderFlag = false;// 催单按钮
          this.frmLossOrderFlag = false;// 备款按钮
          this.complainOrderFlag = true;// 投诉按钮
          this.orderFlag = false;// 恢复订单
          this.journalFlag = true;// 确认订单
          // this.$refs.pendDetail.cakeFlag = false; //蛋糕修改按钮
          break;
        // // 未领备款
        // case 14:
        //   this.returnOrderFlag = false;// 退订按钮
        //   this.refundMoneyFlag = true;// 退款按钮
        //   this.reminderOrderFlag = false;// 催单按钮
        //   this.frmLossOrderFlag = false;// 备款按钮
        //   this.complainOrderFlag = true;// 投诉按钮
        //   this.orderFlag = false;// 恢复订单
        //   break;
        // // 已领备款
        // case 15:
        //   this.returnOrderFlag = false;// 退订按钮
        //   this.refundMoneyFlag = true;// 退款按钮
        //   this.reminderOrderFlag = false;// 催单按钮
        //   this.frmLossOrderFlag = false;// 备款按钮
        //   this.complainOrderFlag = true;// 投诉按钮
        //   this.orderFlag = false;// 恢复订单
        //   break;
        // 改期
        case 16:
          this.returnOrderFlag = false;// 退订按钮
          this.refundMoneyFlag = true;// 退款按钮
          this.reminderOrderFlag = false;// 催单按钮
          this.frmLossOrderFlag = false;// 备款按钮
          this.complainOrderFlag = true;// 投诉按钮
          this.orderFlag = false;// 恢复订单
          this.journalFlag = true;// 确认订单
          // this.$refs.pendDetail.cakeFlag = false; //蛋糕修改按钮
          break;
        default:
          break;
      }
    },
    // 退订弹窗打开
    returnGoodsOpen() {
      let customCakeTypeArray = []
      this.selectArray = [];
      let cakeArray = [];
      this.shoplist.forEach(item => {
        customCakeTypeArray.push(item.goodsTypeName)
        if(item.goodsTypeName == '蛋糕') {
          this.selectArray.push(item.id)
        }
        if(item.goodsTypeName == '配件') {
          this.selectArray.push(item.id)
        }
        if(item.goodsTypeName == '定制蛋糕') {
          this.selectArray.push(item.id)
        }
        if(item.goodsTypeName !== '配件' && item.goodsTypeName !== '蛋糕' && item.goodsTypeName !== '服务费' &&item.goodsTypeName !== '定制蛋糕') {
          cakeArray.push(false)
        }
      })
      if(customCakeTypeArray.indexOf('配件') > -1) {
        this.partsFlag = true;
      }
      if (customCakeTypeArray.indexOf('定制蛋糕') > -1) {
        this.customCakeFlag = true;
      }
      if (customCakeTypeArray.indexOf('蛋糕') > -1) {
        // console.log('Cakeids',this.Cakeids,this.Partsids)
        this.refundCakeFlag = true;
      }
      if(cakeArray.indexOf(false) > -1) {
        this.$message({
          showClose: true,
          message: '退订发起失败，请确认清楚商品类别',
          type: 'warning'
        });
        this.returnGoodsFlag = false;
      } else {
        if(this.ruleForm.status == 1) {
          this.refundFlag = false;
          this.UnsubscribeFlag = true;
          this.preservationFlag = false;
          this.updateKindMessage();
        } else if (this.ruleForm.status > 1) {
          this.UnsubscribeFlag = false;
          this.returnGoodsFlag = true;
          this.preservationFlag = false;
        }
      }
    },
    handleCheckedCitiesChange(e) {
      console.log('e',e.currentTarget);
    },
    // 退订确认按钮
    unsubscribeSubmitForm(e,formName) {
      this.unsubscribeForm.noSelectOrderDetailIds = [];
      let goodsId = [];
      this.unsubscribeForm.parts.forEach(item => {
        goodsId.push(item)
      })
      this.unsubscribeForm.customCake.forEach(item => {
        goodsId.push(item)
      })
      this.unsubscribeForm.orderDetailIds.forEach(item => {
        goodsId.push(item)
      })
      this.unsubscribeForm.noSelectOrderDetailIds = this.selectArray;
      this.unsubscribeForm.selectOrderDetailIds = goodsId;
      // console.log('不含有',this.unsubscribeForm.noSelectOrderDetailIds,'this.selectArray',this.selectArray,'this.unsubscribeForm.selectOrderDetailIds',this.unsubscribeForm.selectOrderDetailIds)
      this.$refs[formName].validate(valid => {
        if (valid) {
          if(this.unsubscribeForm.selectOrderDetailIds.length > 0) {
            this.unsubscribeForm.orderId = e.currentTarget.dataset.id;
            addWorkOrderUnsubscribe(this.unsubscribeForm).then(res => {
              if (res.data.code == 200) {
                this.$refs[formName].resetFields();
                this.returnGoodsFlag = false;
                this.UnsubscribeFlag = false;
                this.getList();
                this.PlaRefundQuery(); // 平台退款中标记消失
                this.$confirm(`退订成功！后台单号：${this.ruleForm.xmbzNo}`, '提示', {
                  showCancelButton: false,
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'success'
                }).then(() => {
                  window.close();
                  // window.opener.location.reload();
                }).catch(() => {
                });
              }
            }).catch(err => {
              this.$refs[formName].resetFields();
              this.returnGoodsFlag = false;
            })
          } else {
            this.$message({
              showClose: true,
              message: '退订发起失败，请选择商品',
              type: 'warning'
            });
          }
        } else {
          return false;
        }
      });
    },
    unsubscribeFormClose() {
      this.$confirm('确认关闭？')
        .then(() => {
          this.$refs['unsubscribeForm'].resetFields();
          this.UnsubscribeFlag = false;
          this.returnGoodsFlag = false;
          done();
        })
        .catch(() => {});
    },
    unsubscribeResetForm(formName) {
      // 退订取消按钮
      this.$refs[formName].resetFields();
      this.UnsubscribeFlag = false;
      this.returnGoodsFlag = false;
    },
    // 退款界面显示
    refundOpen() {
      // console.log('申请退款')
      let orderId = this.ruleForm.id;
      getGoodsByOrderId({orderId}).then(res => {
        console.log('res.data.data',res.data.data);
        this.refundList = res.data.data;
      })
      this.refundForm.orderDetailIds = [];
      this.refundForm.customCake = [];
      this.refundForm.parts = [];
      // this.refundForm.refundMoney = this.refundCakePrice = 0;
      this.RefundShowFlag = true;
      this.RefundNoReShowFlag = false;
      this.getQueryList()
    },
    // 退款不退货界面显示
    RefundNoRe() {
      let orderId = this.ruleForm.id;
      this.RefundNoReShowFlag = true;
      this.RefundShowFlag = false;
      getGoodsByOrderId({orderId}).then(res => {
        console.log('res.data.data',res.data.data);
        this.refundList = res.data.data;
      })
      // console.log('申请退款')
      this.getQueryList()
    },
    // 退款界面打开所需请求的接口、商品类型显隐判断
    getQueryList() {
      let customCakeTypeArray = []
      this.selectArray = []
      let cakeArray = [];
      this.refundForm.compensationMethod = '';
      this.refundForm.sincerityGold = 0;
      this.refundForm.giveCakePrice = 0;
      this.refundForm.giveGiftPrice = 0;
      this.refundForm.cakeCompensatePrice = 0;
      this.shoplist.forEach(item => {
        customCakeTypeArray.push(item.goodsTypeName)
        if(item.goodsTypeName == '蛋糕') {
          this.selectArray.push(item.id)
        }
        if(item.goodsTypeName == '配件') {
          this.selectArray.push(item.id)
        }
        if(item.goodsTypeName == '定制蛋糕') {
          this.selectArray.push(item.id)
        }
        if(item.goodsTypeName !== '配件' && item.goodsTypeName !== '蛋糕' && item.goodsTypeName !== '服务费' &&item.goodsTypeName !== '定制蛋糕') {
          cakeArray.push(false)
        }
      })
      if(cakeArray.indexOf(false) > -1) {
        this.$message({
          showClose: true,
          message: '退款发起失败，请确认清楚商品类别',
          type: 'warning'
        });
        this.refundOpenFlag = false;
      } else {
        if(this.ruleForm.status == 1) {
          this.UnsubscribeFlag = false;
          this.refundFlag = true;
          this.preservationFlag = false;
          this.updateKindMessage();
        } else if (this.ruleForm.status > 1) {
          this.refundOpenFlag = true;
          this.preservationFlag = false;
          this.refundFlag = false;
        }
      }
      if(customCakeTypeArray.indexOf('配件') > -1) {
        this.partsFlag = true;
        // console.log('配件cunzai')
      }
      if (customCakeTypeArray.indexOf('定制蛋糕') > -1) {
        this.customCakeFlag = true;
      }
      if (customCakeTypeArray.indexOf('蛋糕') > -1) {
        this.refundCakeFlag = true;
      }
      getRefundModeList().then(res => {
        // console.log('待生产','待生产',res)
        this.radioList = res.data.data;
      })
      // 退款等级列表getRefundGradeList
      getRefundGradeList().then(res => {
        // console.log(res)
        this.getRefundGradeList = res.data.data;
      });
      // 退款原因列表
      getRefundReasonList().then(res => {
        this.getRefundReasonList = res.data.data;
        // console.log('this.getRefundReasonList,this.getRefundReasonList',this.getRefundReasonList)
      });
      getCompensationMethodList().then(res => {
        // 赔偿方式列表
        this.getCompensationMethodList = res.data.data;
      });
    },
    // 主图开始上传
    handleAvatarSuccess(response, file, fileList) {
      this.temp.mainPic = response.data;
      this.refundForm.refundCode = fileList[fileList.length - 1].response.data;
      // console.log('handleAvatarSuccess',this.refundForm.refundCode,fileList[0].response)
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    }, // 图片预览及删除
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    fileChange(file) {
      this.$refs.upload.clearFiles(); //清除文件对象
      this.logo = file.raw; // 取出上传文件的对象，在其它地方也可以使用
      this.fileList = [{ name: file.name, url: file.url }]; // 重新手动赋值filstList， 免得自定义上传成功了, 而fileList并没有动态改变， 这样每次都是上传一个对象
    },
    refundReasonOpen(val) {
      // console.log(val);
      this.refundReaList.name = val;
      getRefundTypeList(this.refundReaList).then(res => {
        // 退款类型列表
        this.getRefundTypeList = res.data.data;
      });
    },
    compensationMethodOpen(val) {
      console.log(val);
    },
    // 退款，赔偿
    getRadio(val) {
      if(val == 1 ) {
        // this.refundForm.refundMoney = this.refundCakePrice
        this.refundRadioFlag = true
        this.payforRadioFlag = false
        this.compensationMethodFlag = false
        this.refundForm.cakeCompensatePrice = ''
        this.refundForm.sincerityGold = 0
        this.refundForm.giveCakePrice = 0
        this.refundForm.giveGiftPrice = 0
      } else {
        this.refundForm.cakeCompensatePrice = 0
        // this.refundForm.refundMoney = ''
        this.payforRadioFlag = true
        this.refundRadioFlag = false
        this.compensationMethodFlag = true
        this.refundForm.compensationMethod = 6
      }
    },
    // 赔偿方式
    getcompensationMethodRadio(val) {
      if(val == 6) {
        // console.log('000000')
        this.compensationMethodFlag = true
        this.refundForm.cakeCompensatePrice = 0
        // this.refundForm.refundMoney = 0
      } else if (val == 1) {
        // this.refundForm.refundMoney = 0
        this.compensationMethodFlag = true
        this.refundForm.cakeCompensatePrice = this.refundCakePrice
      } else if (val == 2) {
        // this.refundForm.refundMoney = 0
        this.compensationMethodFlag = true
        this.refundForm.cakeCompensatePrice = this.refundCakePrice/2
      }
    },
    // 退款模块获取蛋糕价格
    getTotalprice() {
      this.getrefundAmount();
    },
    // 退款模块获取定制蛋糕价格
    getCustomprice() {
      this.getrefundAmount();
    },
    // 退款模块获取配件价格
    getPartsprice() {
      this.getrefundAmount();
    },
    // 获取退款不同商品类型的蛋糕的价格
    getrefundAmount() {
      let orderDetailIds = [];
      this.refundForm.orderDetailIds.forEach(item => {
        orderDetailIds.push(item)
      })
      this.refundForm.customCake.forEach(item => {
        orderDetailIds.push(item)
      })
      this.refundForm.parts.forEach(item => {
        orderDetailIds.push(item)
      })
      if(orderDetailIds.length > 0) {
        let cakePrice = [];
        let cakeSumPrice = 0;
        orderDetailIds.forEach((item,valueindex) => {
          this.shoplist.forEach((shopitem,shopindex) => {
            if(item == shopitem.id) {
              cakePrice.push(this.shoplist[shopindex].totalPrice);
            }
          })
        })
        cakePrice.forEach((item,priceindex) => {
          cakeSumPrice += cakePrice[priceindex];
        })
        this.refundCakePrice = cakeSumPrice/100
        // this.refundForm.refundMoney = this.refundCakePrice
        if(this.refundForm.compensationMethod == 6) {
          this.refundForm.cakeCompensatePrice = 0
        } else if (this.refundForm.compensationMethod == 1) {
          this.refundForm.cakeCompensatePrice = this.refundCakePrice
        } else if (this.refundForm.compensationMethod == 2) {
          this.refundForm.cakeCompensatePrice = this.refundCakePrice/2
        }
      } else {
        this.refundCakePrice = 0.00;
        // this.refundForm.refundMoney = this.refundCakePrice;
        if(this.refundForm.compensationMethod == 6) {
          this.refundForm.cakeCompensatePrice = 0
        } else if (this.refundForm.compensationMethod == 1) {
          this.refundForm.cakeCompensatePrice = this.refundCakePrice
        } else if (this.refundForm.compensationMethod == 2) {
          this.refundForm.cakeCompensatePrice = this.refundCakePrice/2
        }
      }
    },
    refundFormClose() { // 关闭退款弹窗
      this.$confirm('确认关闭？')
        .then(() => {
          this.refundOpenFlag = false;
          this.refundFlag = false;
          this.refundForm.refundCode = '';
          this.temp.mainPic = '';
          this.RefundNoReShowFlag = false;
          this.RefundShowFlag = false;
          this.$refs['refundForm'].resetFields();
          done();
        })
        .catch(() => {});
    },
    // 退款确认按钮
    refundSubmitForm(e, formName) {
      this.refundForm.noSelectOrderDetailIds = []
      let goodsId = []
      this.refundForm.parts.forEach(item => {
        goodsId.push(item)
      })
      this.refundForm.customCake.forEach(item => {
        goodsId.push(item)
      })
      this.refundForm.orderDetailIds.forEach(item => {
        goodsId.push(item)
      })
      // console.log('配水间',goodsId,'定制单狗')
      this.refundForm.noSelectOrderDetailIds = this.selectArray
      this.refundForm.selectOrderDetailIds = goodsId
      // console.log('未选中',this.refundForm.noSelectOrderDetailIds,'选中',this.refundForm.selectOrderDetailIds)
      // if(this.refundForm.refundMode == 1) {
      //   // console.log(1)
      //   this.refundForm.refundMoney = this.refundCakePrice
      // } else {
      //   // console.log(2)
      //   this.refundForm.refundMoney = Number(this.refundForm.cakeCompensatePrice) + Number(this.refundForm.sincerityGold) + Number(this.refundForm.giveCakePrice) + Number(this.refundForm.giveGiftPrice)
      // }
      // this.refundForm.refundMoney = Number(this.refundCakePrice) + Number(this.refundForm.sincerityGold) + Number(this.refundForm.giveCakePrice) + Number(this.refundForm.giveGiftPrice)
      this.refundForm.orderId = e.currentTarget.dataset.id;
      // console.log(this.refundForm,this.refundForm.refundMoney);
      this.$refs[formName].validate(valid => {
        if (valid) {
          if(this.refundForm.selectOrderDetailIds.length > 0) {
            console.log("222", this.refundForm);
            // 退款
            if(this.RefundShowFlag) {
              addWorkOrderRefund(this.refundForm)
                .then(res => {
                  if (res.data.code == 200) {
                    this.$refs[formName].resetFields();
                    this.refundOpenFlag = false;
                    this.refundFlag = false;
                    this.getList();
                    this.refundForm.orderId = '';
                    this.refundForm.sincerityGold = '';
                    this.refundForm.giveCakePrice = '';
                    this.refundForm.giveGiftPrice = '';
                    this.refundForm.refundCode = '';
                    this.temp.mainPic = '';
                    this.PlaRefundQuery(); // 平台退款中标记消失
                    this.$confirm(`退款成功！后台单号：${this.ruleForm.xmbzNo}`, '提示', {
                      showCancelButton: false,
                      confirmButtonText: '确定',
                      cancelButtonText: '取消',
                      type: 'success'
                    }).then(() => {
                      window.close();
                      this.RefundShowFlag = false;
                      this.RefundNoReShowFlag = false;
                      // window.opener.location.reload();
                    }).catch(() => {
                    });
                  }
                }).catch(err => {
                  this.$refs[formName].resetFields();
                  this.refundOpenFlag = false;
                  this.RefundShowFlag = false;
                  this.RefundNoReShowFlag = false;
                  this.refundForm.compensationMethod = '';
                })
            } else if(this.RefundNoReShowFlag) {
              // 退款不退货
              addRefundNotReturn(this.refundForm)
                .then(res => {
                  if (res.data.code == 200) {
                    this.$refs[formName].resetFields();
                    this.refundOpenFlag = false;
                    this.refundFlag = false;
                    this.getList();
                    this.refundForm.orderId = '';
                    this.refundForm.sincerityGold = '';
                    this.refundForm.giveCakePrice = '';
                    this.refundForm.giveGiftPrice = '';
                    this.refundForm.refundCode = '';
                    this.temp.mainPic = '';
                    this.PlaRefundQuery(); // 平台退款中标记消失
                    this.$confirm(`退款成功！后台单号：${this.ruleForm.xmbzNo}`, '提示', {
                      showCancelButton: false,
                      confirmButtonText: '确定',
                      cancelButtonText: '取消',
                      type: 'success'
                    }).then(() => {
                      window.close();
                      this.RefundNoReShowFlag = false;
                      this.RefundShowFlag = false;
                      // window.opener.location.reload();
                    }).catch(() => {
                    });
                  }
                }).catch(err => {
                  this.$refs[formName].resetFields();
                  this.refundOpenFlag = false;
                  this.RefundNoReShowFlag = false;
                  this.RefundShowFlag = false;
                  this.refundForm.compensationMethod = '';
                })
            }
            
          } else {
            this.$message({
              showClose: true,
              message: '退款发起失败，请选择商品',
              type: 'warning'
            });
          }
        } else {
          // console.log("error submit!!");
          this.$message({
            message: '信息未填完整',
            type: 'warning'
          });
          // this.$notify({  2475457914530816
          //   title: "警告",
          //   message: "信息未填完整",
          //   type: "warning"
          // });
          return false;
        }
      });
    },
    // 退款取消按钮
    refundResetForm(formName) {
      this.$refs[formName].resetFields();
      this.refundForm.refundCode = '';
      this.refundOpenFlag = false;
      this.refundFlag = false;
      this.RefundNoReShowFlag = false;
      this.RefundShowFlag = false;
      // this.$refs.upload.clearFiles(); //清除文件对象
      this.temp.mainPic = '';
    },
    // 恢复订单
    recoverOpen() {
      this.recoverOrderFlag = true;
    },
    recoverSubmitForm(e, formName) {
      this.recoverForm.orderId = e.currentTarget.dataset.id;
      this.$refs[formName].validate(valid => {
        if (valid) {
          getRecoveryOrder(this.recoverForm).then(res => {
            if (res.data.code == 200) {
              this.$notify({
                title: "恢复订单成功",
                message: "请您耐心等待",
                type: "success"
              });
              this.$refs[formName].resetFields();
            }
          });
        } else {
          return false;
        }
      });
    },
    recoverResetForm(formName) {
      this.$refs[formName].resetFields();
      this.recoverOrderFlag = false;
    },
    reminderOpen() {
      // 催单
      this.reminderFlag = true;
      // 催单类型列表
      getReminderTypeList().then(res => {
        // console.log(res.data.data);
        this.reminderList = res.data.data;
      });
    },
    // 催单确认按钮
    reminderSubmitForm(e, formName) {
      this.reminderForm.orderId = e.currentTarget.dataset.id;
      this.$refs[formName].validate(valid => {
        if (valid) {
          addWorkOrderReminder(this.reminderForm).then(res => {
            if (res.data.code == 200) {
              this.$refs[formName].resetFields();
              this.reminderFlag = false;
              this.$confirm(`催单成功！后台单号：${this.ruleForm.xmbzNo}`, '提示', {
                showCancelButton: false,
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'success'
              }).then(() => {
                window.close();
                // window.opener.location.reload();
              }).catch(() => {
              });
            }
          });
        } else {
          return false;
        }
      });
    },
    // 催单取消按钮
    reminderResetForm(formName) {
      this.$refs[formName].resetFields();
      this.reminderFlag = false;
    },
    // 备款
    frmLossOpen() {
      this.frmLossFlag = true;
      let customCakeTypeArray = []
      this.selectArray = []
      this.Cakesids = []
      this.shoplist.forEach(item => {
        customCakeTypeArray.push(item.goodsTypeName)
        if(item.goodsTypeName == '蛋糕') {
          this.selectArray.push(item.id)
          this.Cakesids.push(item.id)
        }
        if(item.goodsTypeName == '配件') {
          this.selectArray.push(item.id)
        }
        if(item.goodsTypeName == '定制蛋糕') {
          this.selectArray.push(item.id)
        }
      })
      if (customCakeTypeArray.indexOf('蛋糕') > -1) {
        this.refundCakeFlag = true;
      }
      // 备款责任部门
      getResponsibleDepartmentList().then(res => {
        this.frmLossList = res.data.data;
      });
      // 备款来源
      getProvisionsOperationList().then(res => {
        // console.log(res.data.data)
        this.getSourceList = res.data.data;
      });
    },
    idProvisionsOperation() {
      if (this.frmLossForm.provisionsOperation == 1) {
        this.refundCakeFlag = true;
        this.frmLossTimeFlag = false;
      } else if (this.frmLossForm.provisionsOperation == 2) {
        this.refundCakeFlag = false;
        this.frmLossTimeFlag = true;
      }
    },
    frmLossSubmitForm(e, formName) {
      // 备款确认按钮
      // // console.log('配水间',goodsId,'定制单狗')
      // console.log(this.frmLossForm.orderDetailIds,'this.frmLossForm.orderDetailId',this.frmLossForm,'未选中的',this.Cakesids)
      this.$refs[formName].validate(valid => {
        if (valid) {
          // console.log("this.frmLossForm.unsubscribeReason",this.frmLossForm.unsubscribeReason)
          const frmLossCancelForm = {// 备款退订请求参数
            orderId: e.currentTarget.dataset.id, //后台单号
            orderDetailIds:  this.frmLossForm.orderDetailIds,//详情id
            personDept:  this.frmLossForm.personDept, //部门
            personLiable:  this.frmLossForm.personLiable, //责任人
            cakeWhereabouts:  this.frmLossForm.cakeWhereabouts, //蛋糕去向
            provisionsContent:  this.frmLossForm.provisionsContent, //备款内容
            provisionsOperation:  this.frmLossForm.provisionsOperation, //备款来源
            isProduction:  this.frmLossForm.isProduction, // 是否生产
            applyReason:  this.frmLossForm.applyReason, // 申请原因
            unsubscribeReason:  this.frmLossForm.unsubscribeReason, // 退订原因
          }
          this.frmLossForm.orderId = e.currentTarget.dataset.id;
          if (this.frmLossForm.provisionsOperation == 1) {
            if(this.frmLossForm.orderDetailIds == undefined) {
              this.$message({
                message: '备款蛋糕不能为空',
                type: 'warning'
              });
            }
            if(this.frmLossForm.unsubscribeReason == undefined) {
              this.$message({
                message: '退订原因不能为空',
                type: 'warning'
              });
            }
            if(this.frmLossForm.applyReason == undefined) {
              this.$message({
                message: '申请原因不能为空',
                type: 'warning'
              });
            }
            if(this.frmLossForm.orderDetailIds !== undefined && this.frmLossForm.unsubscribeReason !== undefined && this.frmLossForm.applyReason !== undefined) {
              addWorkOrderProvisions(frmLossCancelForm).then(res => {
                if (res.data.code == 200) {
                  this.getList();
                  this.frmLossForm.unsubscribeReason = ''
                  this.frmLossForm.applyReason = ''
                  this.frmLossForm.orderDetailIds = ''
                  this.$refs[formName].resetFields();
                  this.frmLossFlag = false;
                  this.PlaRefundQuery(); // 平台退款中标记消失
                  this.$confirm(`备款成功！后台单号：${this.ruleForm.xmbzNo}`, '提示', {
                    showCancelButton: false,
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    center: true,
                    type: 'success'
                  }).then(() => {
                    window.close();
                    // window.opener.location.reload();
                  }).catch(() => {
                  });
                  // console.log('1')
                }
              }).catch(err => {
                console.log(err);
              })
            }
          } else if (this.frmLossForm.provisionsOperation == 2) {
            if(this.$refs.getdeliveryTime !== undefined && this.$refs.getdeliveryTime.deliveryStartTime !== '' && this.$refs.getdeliveryTime.deliveryEndTime !== '') {
              this.frmLossForm.distributionStartTime = this.$refs.getdeliveryTime.deliveryTime+this.$refs.getdeliveryTime.deliveryStartTime
              this.frmLossForm.distributionEndTime = this.$refs.getdeliveryTime.deliveryTime+this.$refs.getdeliveryTime.deliveryEndTime
              this.frmLossForm.orderDetailIds = this.Cakesids;
              this.getDelivery(this.frmLossForm.distributionStartTime);
              if(this.getDeliveryFlag) {
                addWorkOrderProvisions(this.frmLossForm).then(res => {
                  if (res.data.code == 200) {
                    this.$confirm(`<div style="text-align: left;margin-left: 8px;">备款成功！后台单号：${this.ruleForm.xmbzNo}</div><br/><div style="text-align: left;margin-left: 8px;">${res.data.data}</div>`, '提示', {
                      showCancelButton: false,
                      confirmButtonText: '确定',
                      cancelButtonText: '取消',
                      dangerouslyUseHTMLString: true,
                      center: true,
                      type: 'success'
                    }).then(() => {
                      window.close();
                      // window.opener.location.reload();
                    }).catch(() => {
                    });
                    this.getList();
                    this.frmLossForm.distributionStartTime = ''
                    this.frmLossForm.distributionEndTime = ''
                    this.frmLossForm.orderDetailIds = ''
                    this.$refs[formName].resetFields();
                    this.frmLossFlag = false;
                    this.PlaRefundQuery(); // 平台退款中标记消失
                    // console.log('2')
                  }
                });
              } else {
                this.$message.warning("该时间已过期，请重新选择");
              }

            } else {
              this.$alert(`您还未选配送时间，请选择配送时间`, '提示', {
              confirmButtonText: '确定',
                callback: action => {
                  this.$message({
                    type: 'warning',
                    message: `请继续选择配送时间`
                  });
                }
              })
            }
          }
        } else {
          return false;
        }
      });
    },
    frmLossResetForm(formName) {
      // 备款取消按钮
      this.$refs[formName].resetFields();
      this.frmLossFlag = false;
      this.getList();
    },
    complainOpen() {
      // 投诉
      this.complainFlag = true;
      getComplaintLevelList().then(res => {
        // 投诉等级列表
        this.getComplaintLevelList = res.data.data;
      });
      getComplaintChannelList().then(res => {
        // 投诉渠道列表
        this.getComplaintChannelList = res.data.data;
      });
    },
    // 投诉确认按钮
    complainSubmitForm(e, formName) {
      this.complainForm.orderId = e.currentTarget.dataset.id;
      this.$refs[formName].validate(valid => {
        if (valid) {
          addWorkOrderComplaint(this.complainForm).then(res => {
            if (res.data.code == 200) {
              this.$refs[formName].resetFields();
              this.complainFlag = false;
              this.$confirm(`投诉成功！后台单号：${this.ruleForm.xmbzNo}`, '提示', {
                showCancelButton: false,
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'success'
              }).then(() => {
                window.close();
                // window.opener.location.reload();
              }).catch(() => {
              });
            }
          });
        } else {
          return false;
        }
      });
    },
    // 投诉取消按钮
    complainResetForm(formName) {
      this.$refs[formName].resetFields();
      this.complainFlag = false;
    },
    openEditCake() { // 打开蛋糕弹窗
      this.tableData = this.shoplist;
      this.sumPrice = 0;
      this.tableData.forEach(item => {
        item.price = item.totalPrice;
        item.specs = item.goodsSpecs;
        item.getPrice = item.totalPrice;
        this.sumPrice = this.sumPrice + item.getPrice;
      })
      this.activeName = 'first'; // 编辑蛋糕打开即“商品”
      this.getCakeList();
      // 备款分页列表
      // this.getProvisionsGoodsPageList()
    },
    handleCakeClose() { // 关闭蛋糕弹窗
      // console.log('this.shopcloselist',this.tableData,this.shopcloselist);
      this.$confirm('确认关闭？')
        .then(() => {
          // this.tableData = [];
          this.tableData = JSON.stringify(this.shopcloselist);
          this.tableData = JSON.parse(this.tableData);
          this.shoplist = this.tableData;
          // console.log('this.shoplist',this.shoplist)
          this.tableData.forEach(item => {
            item.price = item.totalPrice
            item.specs = item.goodsSpecs
            item.getPrice = item.totalPrice
          })
          this.sumPrice = this.ruleForm.totalPrice;
          this.openEditCakeFlag = false;
        })
        .catch(() => {});
    },
    // 普通蛋糕分页列表
    getCakeList() {
      this.Loading = true;
      if(this.ruleForm.deptId !== '') {
        this.openEditCakeFlag = true;
        // this.activeName = 'second'
        this.productList.deptId = this.ruleForm.deptId;
        shopList(this.productList).then(res => {
          this.shopTotal = res.data.data.total;
          this.list = res.data.data.rows;
        })
      } else {
        this.$message({
          message: '您还未选择城市，请选择城市后再添加蛋糕',
          type: 'warning'
        });
      }
      setTimeout(() => {
        this.Loading = false;
      }, 1.5 * 1000);
    },
    // 备款商品分页列表
    getProvisionsGoodsPageList() {
      this.Loading = true;
      this.getProvisionsGoodsPageQuery.cityId = this.ruleForm.deptId;
      getProvisionsGoodsPage(this.getProvisionsGoodsPageQuery).then(res => {
        this.GoodsPageTotal = res.data.data.total;
        this.getGoodsPageList = res.data.data.rows;
        // console.log(res.data.data,'res.data.data')
      })
      setTimeout(() => {
        this.Loading = false;
      }, 0.5 * 1000);
    },
    // 标签页
    handleClick(tab) {
      console.log(tab.label);
      if(tab.label == '已选蛋糕') {
        let sumCakePrice = 0
        this.tableData.forEach(item => {
          sumCakePrice = sumCakePrice + item.price
        })
        this.sumPrice = sumCakePrice;
      } else if (tab.label == '商品') {
        this.getCakeList(); // 普通蛋糕分页列表
      } else if (tab.label == '备款蛋糕') {
        this.getProvisionsGoodsPageList(); // 备款商品分页列表
      }
    },
    // 普通蛋糕查询
    open() {
      // console.log('this.listMessage.city',this.listMessage.city)
      this.Loading = true;
      this.productList.deptId = this.ruleForm.deptId
      this.productList.name = this.cakeInput;
      shopList(this.productList).then(res => {
        this.shopTotal = res.data.data.total;
        this.list = res.data.data.rows;
      });
      setTimeout(() => {
        this.Loading = false;
      }, 0.5 * 1000);
    },
    // 蛋糕规格（型号）选择
    choiceCheck(cakeing,index,e) {
      cakeing = JSON.stringify(cakeing);
      cakeing = JSON.parse(cakeing);
      this.cakelist = cakeing;
      this.skuId = e.currentTarget.dataset.id;
    },
    // 添加蛋糕
    addEditCake(item) {
      // console.log('this.ruleForm.warehouseId',this.ruleForm.warehouseId,this.ruleForm.branchWarehouse)
      this.judgeGoodsCloseQuery.warehouseId = this.ruleForm.warehouseId;
      let goodsSkuVOS = [];
      this.tableData.forEach(cakeitem => {
        goodsSkuVOS.push(cakeitem.skuCode)
        // console.log('item',item,'cakeitem',cakeitem)
      })
      // console.log('goodsSkuVOS',goodsSkuVOS,item.goodsSkuVOS[0].skuCode,goodsSkuVOS.indexOf(item.goodsSkuVOS[0].skuCode))
      if(this.judgeGoodsCloseQuery.warehouseId !== '' && this.judgeGoodsCloseQuery.warehouseId !== undefined && this.ruleForm.branchWarehouse !== null && this.ruleForm.branchWarehouse !== '' && this.ruleForm.branchWarehouse !== undefined) {
        // if(goodsSkuVOS.indexOf(item.goodsSkuVOS[0].skuCode) == -1) {
          if(item.id == this.cakelist.goodsId) {
            this.cakelist.skuId = this.skuId;
            this.cakelist.id = '';
            this.cakelist.goodsSpecs = this.cakelist.specs; // 尺寸
            this.cakelist.goodsName = this.cakelist.goodsName; // 蛋糕名称
            this.cakelist.skuCode = this.cakelist.skuCode;
            this.cakelist.goodsId = this.cakelist.goodsId;
            this.cakelist.originalPrice = this.cakelist.price;
            this.cakelist.totalPrice = this.cakelist.price;
            this.cakelist.getPrice = this.cakelist.price;
            this.cakelist.orderId = this.ruleForm.xmbzNo;
            this.cakelist.goodsTypeName = this.cakelist.categoryName;
            this.cakelist.workOrderProvisionsDTOList = [];
            this.cakelist.workOrderProvisionsIds = [];
            this.cakelist.num = 1;
            this.cakelist.cake = 1;
            this.cakelist.productionState = 1;
            this.cakelist.productionStateName = "未确认";
            this.judgeGoodsCloseQuery.skuCode = this.cakelist.skuCode;
            judgeGoodsClose(this.judgeGoodsCloseQuery).then(res => {
              if(res.data.code == 200) {
                if(res.data.data == true) {
                  this.$message({
                    showClose: true,
                    message: '添加蛋糕失败，所选仓库没有生产该蛋糕的原料。',
                    type: 'warning'
                  });
                } else if (res.data.data == false) {
                  this.$message({
                    showClose: true,
                    message: '添加蛋糕成功',
                    type: 'success'
                  });
                  if (this.shoplist.length === 0 && this.tableData.length === 0) {
                    // this.shoplist[0] = this.cakelist;
                    this.tableData[0] = this.cakelist
                  } else {
                    // this.shoplist.push(this.cakelist);
                    this.tableData.push(this.cakelist)
                  }
                  this.showPrice()
                  this.tableData = JSON.stringify(this.tableData);
                  this.tableData = JSON.parse(this.tableData);
                }
                this.cakelist = ''
              }
            })
          }
        // } else {
        //   this.$message({
        //     message: '此蛋糕已经添加过，请不要重复添加',
        //     type: 'warning'
        //   });
        // }
      } else {
        this.$message({
          message: '您还未选择仓库，请选择仓库后再添加蛋糕',
          type: 'warning'
        });
      }
    },
    //备款商品分页列表(查询)
    ProvisionsGoodsPageopen() {
      this.Loading = true;
      if(this.getGoodsPageList !== '') {
        this.getProvisionsGoodsPageQuery.cityId = this.listMessage.city;
        this.getProvisionsGoodsPageQuery.goodsName = this.input;
        getProvisionsGoodsPage(this.getProvisionsGoodsPageQuery).then(res => {
          this.GoodsPageTotal = res.data.data.total;
          this.getGoodsPageList = res.data.data.rows
          // console.log(res.data.data,'res.data.data查到了')
        })
        setTimeout(() => {
          this.Loading = false;
        }, 0.5 * 1000);
      }
    },
    // 备款蛋糕规格（型号）选择
    choiceGoodsCheck(cakeMessage) {
      this.judgeGoodsCloseQuery.warehouseId = this.ruleForm.warehouseId;
      let goodsSkuVOS = [];
      this.tableData.forEach(cakeitem => {
        goodsSkuVOS.push(cakeitem.skuCode)
      })
      if(this.judgeGoodsCloseQuery.warehouseId !== '' && this.judgeGoodsCloseQuery.warehouseId !== undefined && this.ruleForm.branchWarehouse !== null && this.ruleForm.branchWarehouse !== '' && this.ruleForm.branchWarehouse !== undefined) {
        if(goodsSkuVOS.indexOf(cakeMessage.skuCode) == -1) {
          cakeMessage.price = cakeMessage.cakePrice;
          cakeMessage.totalPrice = cakeMessage.cakePrice;
          cakeMessage.originalPrice = cakeMessage.cakePrice;
          cakeMessage.specs = cakeMessage.goodsSpecs; // 尺寸
          cakeMessage.goodsName = cakeMessage.goodsName; // 蛋糕名称
          cakeMessage.skuId = cakeMessage.id;
          cakeMessage.workOrderProvisionsIds = [];
          cakeMessage.workOrderProvisionsIds.push(cakeMessage.id);
          cakeMessage.skuCode = cakeMessage.skuCode;
          cakeMessage.goodsId = cakeMessage.goodsId;
          cakeMessage.price = cakeMessage.cakePrice;
          cakeMessage.getPrice = cakeMessage.cakePrice;
          cakeMessage.num = cakeMessage.cakeNum;
          cakeMessage.goodsTypeName = cakeMessage.categoryName;
          // cakeMessage.blessings = '';
          cakeMessage.cake = 1;
          cakeMessage.productionState = 4;
          cakeMessage.id = '';
          cakeMessage.productionStateName = "已入库";
          cakeMessage.workOrderProvisionsDTOList = [];
          cakeMessage.workOrderProvisionsType = '备款';
          this.judgeGoodsCloseQuery.skuCode = cakeMessage.skuCode;
          judgeGoodsClose(this.judgeGoodsCloseQuery).then(res => {
            // console.log('判断当前商品是否关闭',res.data.data)
            if(res.data.code == 200) {
              if(res.data.data == true) {
                this.$message({
                  showClose: true,
                  message: '添加蛋糕失败，所选仓库没有生产该蛋糕的原料。',
                  type: 'warning'
                });
              } else if (res.data.data == false) {
                this.$message({
                  showClose: true,
                  message: '添加蛋糕成功',
                  type: 'success'
                });
                if (this.shoplist.length === 0 && this.tableData.length === 0) {
                  // this.shoplist[0] = cakeMessage;
                  this.tableData[0] = cakeMessage;
                } else {
                  this.tableData.push(cakeMessage);
                  // this.shoplist.push(cakeMessage);
                }
                // console.log('this.tableData',this.tableData)
                this.tableFlag = true;
                this.showPrice()
              }
            }
          })
        } else {
          this.$message({
            message: '此蛋糕已经添加过，请不要重复添加',
            type: 'warning'
          });
        }
      } else {
        this.$message({
          message: '您还未选择仓库，请选择仓库后再添加蛋糕',
          type: 'warning'
        });
      }
    },
    // 蛋糕提交
    onAddSumbit(sumPrice) {
      this.openEditCakeFlag = false
      if(this.tableData.length == 0) {
        this.noEditCakeFlag = true;
        this.ruleForm.orderDetailRequests = [];
        this.ruleForm.sumPrice = (sumPrice/100).toFixed(2);
      } else {
        this.shoplist = this.tableData;
        this.noEditCakeFlag = false;
        this.ruleForm.sumPrice = (sumPrice/100).toFixed(2);
        // console.log('table',this.shoplist)
      }
      let orderSubmitGoodsTimeQuery = {
        orderId: this.ruleForm.id,
        orderStatus: this.orderStatus,
        orderType: 1,
        workType: 0
      }
      orderSubmitGoodsTime(orderSubmitGoodsTimeQuery).then(res => {
        console.log('res',res.data)
      }).catch(error => {
        console.log(error)
      })
    },
    showPrice() { // 计算蛋糕价格
      this.sumPrice = 0
      this.tableData.forEach((value,index) => {
        if(this.tableData.length === 1 ) {
          this.sumPrice = value.getPrice
        } else if(this.tableData.length > 1) {
          this.sumPrice += value.getPrice
        }
      })
    },
    // 删除单个订单
    cleanOrder(index,e) {
      this.$delete(this.tableData,index)
      this.showPrice()
    },
    // 商品类型列表
    getCategories() {
      getCategories("").then(res => {
        const batchdata = res.data.data;
        const dataValueBatch = batchdata =>
          batchdata.map(
            ({
              id,
              categoryName,
              children
            }) =>
            children ? {
              value: id,
              label: categoryName,
              disabled: categoryName == '未知分组' ? true : false,
              children: dataValueBatch(children)
            } : {
              value: id,
              label: categoryName
            }
          );
        this.getCategoriesList = dataValueBatch(batchdata);
        // console.log('getCategoriesList',this.getCategoriesList)
      })
    },
    //选择蛋糕类型
    selectCategory(selected,index) {
      // this.ruleForm.goodsTypeName = selected;
      this.getCategoriesList.forEach(item => {
        // console.log('item',item)
        if(selected[0] == item.value) {
          // console.log('selected[0]',selected[0],selected[1],item.label,index)
          this.shoplist[index].parentCategoryId = selected[0];
          this.shoplist[index].categoryId = selected[1];
          this.shoplist[index].goodsTypeName = item.label;
        }
      })
    },
    // 备注空格问题
    filterSpace(data) {
      if(data === 'customerNotes') {
        this.ruleForm.customerNotes = this.ruleForm.customerNotes.replace(/^\s+|\s+$/g, '')
      } else if(data === 'productionNotes') {
        this.ruleForm.productionNotes = this.ruleForm.productionNotes.replace(/^\s+|\s+$/g, '')
      } else if(data === 'deliveryNotes') {
        // this.ruleForm.deliveryNotes = this.deliveryTimeNotes + '#' + this.ruleForm.deliveryNotes.substring(this.ruleForm.deliveryNotes.lastIndexOf("#"));
        this.ruleForm.deliveryNotes = this.ruleForm.deliveryNotes.replace(/^\s+|\s+$/g, '');
      } else if(data === 'customerServiceNotes') {
        this.ruleForm.customerServiceNotes = this.ruleForm.customerServiceNotes.replace(/^\s+|\s+$/g, '')
      }
    },
    imgclick() {
      this.imgFlag = true;
    },
    // 平台退款中按钮请求
    PlaRefund() {
      let PlaRefundQuery = {
        id: this.ruleForm.id,
        type: 1,
        extKey: 'REFUNDM_MARK'
      };
      if(this.ruleForm.refundMark == '平台退款中') {
        this.$confirm('是否确认取消平台退款?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          // this.confirmUpdate();
          console.log('PlaRefundQuery',PlaRefundQuery)
          deleteOrderExt(PlaRefundQuery).then(res => {
            this.$message.success('已取消平台退款')
            this.getList();
            window.localStorage.setItem('routerFlag', true);
            setTimeout(() => {
              window.close();
              // window.opener.location.reload();
            }, 1.5 * 1000);
          }).catch(error => {
            console.log(error)
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          });          
        });
      }
    },
    // 平台退款请求
    PlaRefundQuery() {
      let PlaRefundQuery = {
        id: this.ruleForm.id,
        type: 2,
        extKey: 'REFUNDM_MARK'
      };
      if(this.ruleForm.refundMark == '平台退款中') {
        deleteOrderExt(PlaRefundQuery).then(res => {
          console.log('res');
        }).catch(error => {
          console.log(error)
        })
      }
    },
    // 电话号码限制
    filterPhone(val) {
      // console.log('va',val)
      this.ruleForm.receiverPhone = val.replace(/[^\d]/g,'');
    },
    overTimeOrder() {
      this.detailtimer = setInterval(() => {
        this.timeNumbers += 1;
        if(this.timeNumbers > 300) {
          clearInterval(this.detailtimer);
          this.timeNumbersFlag = true;
        }
        if(this.timeNumbersFlag) {
          this.$confirm('你锁住此订单已经超过5分钟', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            showCancelButton: false,// 取消按钮
            showClose: false,// 右上角关闭按钮
            closeOnClickModal: false,// 点击遮罩
            closeOnPressEscape: false,// 通过按下 ESC 键关闭
            customClass: 'timeNumbers',
          }).then(() => {
            this.timeNumbers = 0;
            this.timeNumbersFlag = false;
            this.overTimeOrder();
          })
          document.onkeydown = function(e) {//按下回车弹窗消失
            let key = window.event.keyCode;
            //事件中keycode=13为回车事件
            if (key == 13) {
              if(e.target.type !== 'button') {
                let clickBtn = e.target.firstElementChild.firstElementChild.nextElementSibling.nextElementSibling.firstElementChild;
                clickBtn.click();
              }
            }
          };
        }
      }, 1000)
    }
  },
  beforeDestroy() {
    if (this.detailtimer) {
      clearInterval(this.detailtimer); // 在Vue实例销毁前，清除我们的定时器
    }
  }
}
</script>

<style lang="scss">
@import '@/styles/orderdetail.scss';
.refundcake {
  display: flex;
  flex-wrap: wrap;
}
.refundcakeFlag {
  margin: 15px 10px;
  .el-checkbox {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 15px;
    .el-checkbox__label {
      display: flex;
    }
  }
}
.deliveryTimeStyle {
  .el-form-item__content {
    display: flex;
    flex-direction: column;
  }
}
// 在填充数据之前隐藏
[v-cloak] {
  display: none;
}
</style>
